DPDK patches and discussions
 help / color / mirror / Atom feed
From: Pablo de Lara <pablo.de.lara.guarch@intel.com>
To: gaetan.rivet@6wind.com
Cc: dev@dpdk.org, Pablo de Lara <pablo.de.lara.guarch@intel.com>
Subject: [dpdk-dev] [PATCH] eal: fix build with gcc 4.7
Date: Mon, 16 Jul 2018 07:26:27 +0100	[thread overview]
Message-ID: <20180716062627.29814-1-pablo.de.lara.guarch@intel.com> (raw)

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 <pablo.de.lara.guarch@intel.com>
---
 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

             reply	other threads:[~2018-07-16 14:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-16  6:26 Pablo de Lara [this message]
2018-07-16 20:52 ` Gaëtan Rivet
2018-07-18  9:02   ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180716062627.29814-1-pablo.de.lara.guarch@intel.com \
    --to=pablo.de.lara.guarch@intel.com \
    --cc=dev@dpdk.org \
    --cc=gaetan.rivet@6wind.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).