From patchwork Fri Sep 17 15:12:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rebecca Troy X-Patchwork-Id: 99210 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6C4E0A0C43; Fri, 17 Sep 2021 17:12:49 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3AA08410EC; Fri, 17 Sep 2021 17:12:49 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 4E691410E9; Fri, 17 Sep 2021 17:12:47 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10110"; a="222867246" X-IronPort-AV: E=Sophos;i="5.85,301,1624345200"; d="scan'208";a="222867246" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Sep 2021 08:12:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,301,1624345200"; d="scan'208";a="701281071" Received: from silpixa00400904.ir.intel.com ([10.243.23.83]) by fmsmga005.fm.intel.com with ESMTP; 17 Sep 2021 08:12:44 -0700 From: Rebecca Troy To: dev@dpdk.org Cc: roy.fan.zhang@intel.com, Rebecca Troy , fiona.trahe@intel.com, arturx.trybula@intel.com, stable@dpdk.org, Ashish Gupta Date: Fri, 17 Sep 2021 15:12:07 +0000 Message-Id: <20210917151207.2315536-1-rebecca.troy@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH] test/compress: fix buffer overflow bug 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" Fixes stack buffer overflow bug in compressdev autotest, which was caused by the use of buf_idx in the debug logs. Originally, buf_idx was treated as an array instead of the reference of an integar. This was fixed by replacing the use of buf_idx[priv_data->orig_idx] with the variable i. Fixes: 466a2c4bb5f4 ("test/compress: improve debug logs") Fixes: 6bbc5a923625 ("test/compress: refactor unit tests") Cc: fiona.trahe@intel.com Cc: arturx.trybula@intel.com Cc: stable@dpdk.org Signed-off-by: Rebecca Troy Acked-by: Fan Zhang --- app/test/test_compressdev.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/test/test_compressdev.c b/app/test/test_compressdev.c index 0571c17ecb..a1b9f06250 100644 --- a/app/test/test_compressdev.c +++ b/app/test/test_compressdev.c @@ -1411,7 +1411,6 @@ test_deflate_comp_finalize(const struct interim_data_params *int_data, /* from int_data: */ unsigned int num_xforms = int_data->num_xforms; struct rte_comp_xform **compress_xforms = int_data->compress_xforms; - uint16_t *buf_idx = int_data->buf_idx; unsigned int num_bufs = int_data->num_bufs; /* from test_priv_data: */ @@ -1442,7 +1441,7 @@ test_deflate_comp_finalize(const struct interim_data_params *int_data, RTE_LOG(DEBUG, USER1, "Buffer %u compressed by %s from %u to" " %u bytes (level = %d, huffman = %s)\n", - buf_idx[priv_data->orig_idx], engine, + i, engine, ops_processed[i]->consumed, ops_processed[i]->produced, compress_xform->level, huffman_type_strings[huffman_type]); @@ -1734,7 +1733,6 @@ test_deflate_decomp_finalize(const struct interim_data_params *int_data, static unsigned int step; /* from int_data: */ - uint16_t *buf_idx = int_data->buf_idx; unsigned int num_bufs = int_data->num_bufs; const char * const *test_bufs = int_data->test_bufs; struct rte_comp_xform **compress_xforms = int_data->compress_xforms; @@ -1766,7 +1764,7 @@ test_deflate_decomp_finalize(const struct interim_data_params *int_data, strlcpy(engine, "pmd", sizeof(engine)); RTE_LOG(DEBUG, USER1, "Buffer %u decompressed by %s from %u to %u bytes\n", - buf_idx[priv_data->orig_idx], engine, + i, engine, ops_processed[i]->consumed, ops_processed[i]->produced); ops[i] = NULL; }