* [dpdk-dev] [PATCH] eal: fix build with gcc 4.7
@ 2018-07-16 6:26 Pablo de Lara
2018-07-16 20:52 ` Gaëtan Rivet
0 siblings, 1 reply; 3+ messages in thread
From: Pablo de Lara @ 2018-07-16 6:26 UTC (permalink / raw)
To: gaetan.rivet; +Cc: dev, Pablo de Lara
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH] eal: fix build with gcc 4.7
2018-07-16 6:26 [dpdk-dev] [PATCH] eal: fix build with gcc 4.7 Pablo de Lara
@ 2018-07-16 20:52 ` Gaëtan Rivet
2018-07-18 9:02 ` Thomas Monjalon
0 siblings, 1 reply; 3+ messages in thread
From: Gaëtan Rivet @ 2018-07-16 20:52 UTC (permalink / raw)
To: Pablo de Lara; +Cc: dev
Hi Pablo,
On Mon, Jul 16, 2018 at 07:26:27AM +0100, Pablo de Lara wrote:
> 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")
>
Thanks for fixing this.
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Gaetan Rivet <gaetan.rivet@6wind.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
>
--
Gaëtan Rivet
6WIND
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH] eal: fix build with gcc 4.7
2018-07-16 20:52 ` Gaëtan Rivet
@ 2018-07-18 9:02 ` Thomas Monjalon
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2018-07-18 9:02 UTC (permalink / raw)
To: Pablo de Lara; +Cc: dev, Gaëtan Rivet
16/07/2018 22:52, Gaëtan Rivet:
> Hi Pablo,
>
> On Mon, Jul 16, 2018 at 07:26:27AM +0100, Pablo de Lara wrote:
> > 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")
> >
>
> Thanks for fixing this.
>
> > Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> Acked-by: Gaetan Rivet <gaetan.rivet@6wind.com>
Applied, thanks
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-07-18 9:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-16 6:26 [dpdk-dev] [PATCH] eal: fix build with gcc 4.7 Pablo de Lara
2018-07-16 20:52 ` Gaëtan Rivet
2018-07-18 9:02 ` Thomas Monjalon
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).