From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4E4E3A0A02; Wed, 7 Apr 2021 13:00:00 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 334B9140E24; Wed, 7 Apr 2021 13:00:00 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 62D7C140E24 for ; Wed, 7 Apr 2021 12:59:57 +0200 (CEST) IronPort-SDR: lNL7K871TrGWEH1SMscyfVtbu/eS3zqh+B8k8K11nUwlqxApHh7X2G4dhGyWwUs4smepgTJdhO 1j22Iyb14ydQ== X-IronPort-AV: E=McAfee;i="6000,8403,9946"; a="257268566" X-IronPort-AV: E=Sophos;i="5.82,203,1613462400"; d="scan'208";a="257268566" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2021 03:59:56 -0700 IronPort-SDR: ynVppHiGPmbSJRpEKJxSYu7Uw/thQYr5UFdxcxWN39pEPhtjlg31uW/fADrHYTTNZVxfc8Au+J 9kTA2exvX8QQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,203,1613462400"; d="scan'208";a="449071703" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com) ([10.237.223.107]) by fmsmga002.fm.intel.com with ESMTP; 07 Apr 2021 03:59:55 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Date: Wed, 7 Apr 2021 11:59:53 +0100 Message-Id: <20210407105953.18113-1-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] table: fix out of bounds write X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" Fix out of bounds write. The allocated string size was incorrect. Coverity issue: 369670 Fixes: 66440b7b22f2 ("table: add wildcard match table type") Signed-off-by: Cristian Dumitrescu --- lib/librte_table/rte_swx_table_wm.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/librte_table/rte_swx_table_wm.c b/lib/librte_table/rte_swx_table_wm.c index 9924231b3..e260be106 100644 --- a/lib/librte_table/rte_swx_table_wm.c +++ b/lib/librte_table/rte_swx_table_wm.c @@ -53,15 +53,14 @@ env_free(void *start, size_t size) static char *get_unique_name(void) { - char *name; - uint64_t *tsc; + uint64_t tsc = rte_get_tsc_cycles(); + size_t size = sizeof(uint64_t) * 2 + 1; + char *name = calloc(1, size); - name = calloc(7, 1); if (!name) return NULL; - tsc = (uint64_t *) name; - *tsc = rte_get_tsc_cycles(); + snprintf(name, size, "%016" PRIx64, tsc); return name; } -- 2.17.1