From patchwork Wed Oct 28 21:02:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 82682 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 14BB1A04B5; Wed, 28 Oct 2020 22:04:01 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5142F5F18; Wed, 28 Oct 2020 22:03:14 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by dpdk.org (Postfix) with ESMTP id 193ED5A51 for ; Wed, 28 Oct 2020 22:03:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603918987; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VWAs9eXau3WN1I8xOrgrp2BtJIHTk/VhkHybusOzW2M=; b=K0j0Oil/kg+UhrGl3H+d08C0JIAuv5XgSYPedODZ2XlbPk/dsJt2+Cx54HEAlW/AdXRi5z 8ugG8sZOesgjnTaxztsacc12edY3sNly7RV/3jVcS/3CCIilENZBa5SZOvbD/ZARZszA8K yG7tvLYsvkJN4h8AfobrlzNTX7qA44k= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-567-ga-va9gbN2qCKsotOZDUcw-1; Wed, 28 Oct 2020 17:03:05 -0400 X-MC-Unique: ga-va9gbN2qCKsotOZDUcw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6EB5464162; Wed, 28 Oct 2020 21:03:03 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.192.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6885A6266E; Wed, 28 Oct 2020 21:03:02 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: jerinj@marvell.com, skori@marvell.com Date: Wed, 28 Oct 2020 22:02:48 +0100 Message-Id: <20201028210249.9021-4-david.marchand@redhat.com> In-Reply-To: <20201028210249.9021-1-david.marchand@redhat.com> References: <20201023080058.13335-1-david.marchand@redhat.com> <20201028210249.9021-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH v2 3/4] trace: fix metadata dump X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The ctf metadata is written to the metadata file without any check for length, so this string must be null terminated. Fixes: f1a099f5b1f1 ("trace: create CTF TDSL metadata in memory") Signed-off-by: David Marchand Acked-by: Sunil Kumar Kori --- lib/librte_eal/common/eal_common_trace_ctf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/common/eal_common_trace_ctf.c b/lib/librte_eal/common/eal_common_trace_ctf.c index ac1f64d04b..22615c4e73 100644 --- a/lib/librte_eal/common/eal_common_trace_ctf.c +++ b/lib/librte_eal/common/eal_common_trace_ctf.c @@ -37,11 +37,12 @@ meta_copy(char **meta, int *offset, char *str, int rc) if (rc < 0) return rc; - ptr = realloc(ptr, count + rc); + ptr = realloc(ptr, count + rc + 1); if (ptr == NULL) goto free_str; memcpy(RTE_PTR_ADD(ptr, count), str, rc); + ptr[count + rc] = '\0'; count += rc; free(str);