From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 19B3D98 for ; Mon, 16 Jul 2018 16:32:01 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jul 2018 07:31:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,361,1526367600"; d="scan'208";a="67381949" Received: from silpixa00399466.ir.intel.com (HELO silpixa00399466.ger.corp.intel.com) ([10.237.223.220]) by fmsmga002.fm.intel.com with ESMTP; 16 Jul 2018 07:31:58 -0700 From: Pablo de Lara To: gaetan.rivet@6wind.com Cc: dev@dpdk.org, Pablo de Lara Date: Mon, 16 Jul 2018 07:26:27 +0100 Message-Id: <20180716062627.29814-1-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.14.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] eal: fix build with gcc 4.7 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: , X-List-Received-Date: Mon, 16 Jul 2018 14:32:02 -0000 Fixed possible out-of-bounds issue: lib/librte_eal/common/eal_common_devargs.c: In function ‘rte_devargs_layers_parse’: lib/librte_eal/common/eal_common_devargs.c:121:7: error: array subscript is above array bounds Bugzilla ID: 71 Fixes: 338327d731e6 ("devargs: add function to parse device layers") Signed-off-by: Pablo de Lara --- lib/librte_eal/common/eal_common_devargs.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c index a22a2002e..1a7b00ece 100644 --- a/lib/librte_eal/common/eal_common_devargs.c +++ b/lib/librte_eal/common/eal_common_devargs.c @@ -118,12 +118,17 @@ rte_devargs_layers_parse(struct rte_devargs *devargs, } while (s != NULL) { - if (strncmp(layers[i].key, s, - strlen(layers[i].key)) && - /* The last layer is free-form. - * The "driver" key is not required (but accepted). - */ - i != RTE_DIM(layers) - 1) + if (i >= RTE_DIM(layers)) { + RTE_LOG(ERR, EAL, "Unrecognized layer %s\n", s); + ret = -EINVAL; + goto get_out; + } + /* + * The last layer is free-form. + * The "driver" key is not required (but accepted). + */ + if (strncmp(layers[i].key, s, strlen(layers[i].key)) && + i != RTE_DIM(layers) - 1) goto next_layer; layers[i].str = s; layers[i].kvlist = rte_kvargs_parse_delim(s, NULL, "/"); @@ -136,11 +141,6 @@ rte_devargs_layers_parse(struct rte_devargs *devargs, if (s != NULL) s++; next_layer: - if (i >= RTE_DIM(layers)) { - RTE_LOG(ERR, EAL, "Unrecognized layer %s\n", s); - ret = -EINVAL; - goto get_out; - } i++; } -- 2.14.4