* [dpdk-dev] [PATCH v1] examples/vhost: fix string split error handling issue
@ 2020-11-06 3:23 Cheng Jiang
2020-11-10 9:34 ` Maxime Coquelin
2020-11-11 9:08 ` [dpdk-dev] [PATCH v2] " Cheng Jiang
0 siblings, 2 replies; 6+ messages in thread
From: Cheng Jiang @ 2020-11-06 3:23 UTC (permalink / raw)
To: maxime.coquelin, chenbo.xia; +Cc: dev, patrick.fu, YvonneX.Yang, Cheng Jiang
Add checking return value of string split function to fix the
coverity issue.
Fixes: 3a04ecb21420 ("examples/vhost: add async vhost args parsing")
Coverity issue: 363739
Signed-off-by: Cheng Jiang <Cheng1.jiang@intel.com>
---
examples/vhost/ioat.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/examples/vhost/ioat.c b/examples/vhost/ioat.c
index b2c74f6537..04806c02d7 100644
--- a/examples/vhost/ioat.c
+++ b/examples/vhost/ioat.c
@@ -54,9 +54,14 @@ open_ioat(const char *value)
}
args_nr = rte_strsplit(substr, strlen(substr),
dma_arg, MAX_VHOST_DEVICE, ',');
- do {
+ while (i < args_nr) {
char *arg_temp = dma_arg[i];
- rte_strsplit(arg_temp, strlen(arg_temp), ptrs, 2, '@');
+ uint8_t sub_nr;
+ sub_nr = rte_strsplit(arg_temp, strlen(arg_temp), ptrs, 2, '@');
+ if (sub_nr != 2) {
+ ret = -1;
+ goto out;
+ }
start = strstr(ptrs[0], "txd");
if (start == NULL) {
@@ -105,7 +110,7 @@ open_ioat(const char *value)
dma_info->nr++;
i++;
- } while (i < args_nr);
+ }
out:
free(input);
return ret;
--
2.29.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH v1] examples/vhost: fix string split error handling issue
2020-11-06 3:23 [dpdk-dev] [PATCH v1] examples/vhost: fix string split error handling issue Cheng Jiang
@ 2020-11-10 9:34 ` Maxime Coquelin
2020-11-11 0:58 ` Jiang, Cheng1
2020-11-11 9:08 ` [dpdk-dev] [PATCH v2] " Cheng Jiang
1 sibling, 1 reply; 6+ messages in thread
From: Maxime Coquelin @ 2020-11-10 9:34 UTC (permalink / raw)
To: Cheng Jiang, chenbo.xia; +Cc: dev, patrick.fu, YvonneX.Yang
On 11/6/20 4:23 AM, Cheng Jiang wrote:
> Add checking return value of string split function to fix the
> coverity issue.
>
> Fixes: 3a04ecb21420 ("examples/vhost: add async vhost args parsing")
> Coverity issue: 363739
>
> Signed-off-by: Cheng Jiang <Cheng1.jiang@intel.com>
> ---
> examples/vhost/ioat.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/examples/vhost/ioat.c b/examples/vhost/ioat.c
> index b2c74f6537..04806c02d7 100644
> --- a/examples/vhost/ioat.c
> +++ b/examples/vhost/ioat.c
> @@ -54,9 +54,14 @@ open_ioat(const char *value)
> }
> args_nr = rte_strsplit(substr, strlen(substr),
> dma_arg, MAX_VHOST_DEVICE, ',');
I think you should check args_nr > 0 explicitly, and maybe even args_nr
>= 0. And then propagate the error if condition is met.
> - do {
> + while (i < args_nr) {
> char *arg_temp = dma_arg[i];
> - rte_strsplit(arg_temp, strlen(arg_temp), ptrs, 2, '@');
> + uint8_t sub_nr;
> + sub_nr = rte_strsplit(arg_temp, strlen(arg_temp), ptrs, 2, '@');
> + if (sub_nr != 2) {
> + ret = -1;
> + goto out;
> + }
>
> start = strstr(ptrs[0], "txd");
> if (start == NULL) {
> @@ -105,7 +110,7 @@ open_ioat(const char *value)
>
> dma_info->nr++;
> i++;
> - } while (i < args_nr);
> + }
> out:
> free(input);
> return ret;
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH v1] examples/vhost: fix string split error handling issue
2020-11-10 9:34 ` Maxime Coquelin
@ 2020-11-11 0:58 ` Jiang, Cheng1
0 siblings, 0 replies; 6+ messages in thread
From: Jiang, Cheng1 @ 2020-11-11 0:58 UTC (permalink / raw)
To: Maxime Coquelin, Xia, Chenbo; +Cc: dev, Fu, Patrick, Yang, YvonneX
Hi,
> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: Tuesday, November 10, 2020 5:35 PM
> To: Jiang, Cheng1 <cheng1.jiang@intel.com>; Xia, Chenbo
> <chenbo.xia@intel.com>
> Cc: dev@dpdk.org; Fu, Patrick <patrick.fu@intel.com>; Yang, YvonneX
> <yvonnex.yang@intel.com>
> Subject: Re: [PATCH v1] examples/vhost: fix string split error handling issue
>
>
>
> On 11/6/20 4:23 AM, Cheng Jiang wrote:
> > Add checking return value of string split function to fix the coverity
> > issue.
> >
> > Fixes: 3a04ecb21420 ("examples/vhost: add async vhost args parsing")
> > Coverity issue: 363739
> >
> > Signed-off-by: Cheng Jiang <Cheng1.jiang@intel.com>
> > ---
> > examples/vhost/ioat.c | 11 ++++++++---
> > 1 file changed, 8 insertions(+), 3 deletions(-)
> >
> > diff --git a/examples/vhost/ioat.c b/examples/vhost/ioat.c index
> > b2c74f6537..04806c02d7 100644
> > --- a/examples/vhost/ioat.c
> > +++ b/examples/vhost/ioat.c
> > @@ -54,9 +54,14 @@ open_ioat(const char *value)
> > }
> > args_nr = rte_strsplit(substr, strlen(substr),
> > dma_arg, MAX_VHOST_DEVICE, ',');
>
> I think you should check args_nr > 0 explicitly, and maybe even args_nr
> >= 0. And then propagate the error if condition is met.
>
Sure, I'll fix it in the next version.
Thanks,
Cheng
>
> > - do {
> > + while (i < args_nr) {
> > char *arg_temp = dma_arg[i];
> > - rte_strsplit(arg_temp, strlen(arg_temp), ptrs, 2, '@');
> > + uint8_t sub_nr;
> > + sub_nr = rte_strsplit(arg_temp, strlen(arg_temp), ptrs, 2,
> '@');
> > + if (sub_nr != 2) {
> > + ret = -1;
> > + goto out;
> > + }
> >
> > start = strstr(ptrs[0], "txd");
> > if (start == NULL) {
> > @@ -105,7 +110,7 @@ open_ioat(const char *value)
> >
> > dma_info->nr++;
> > i++;
> > - } while (i < args_nr);
> > + }
> > out:
> > free(input);
> > return ret;
> >
^ permalink raw reply [flat|nested] 6+ messages in thread
* [dpdk-dev] [PATCH v2] examples/vhost: fix string split error handling issue
2020-11-06 3:23 [dpdk-dev] [PATCH v1] examples/vhost: fix string split error handling issue Cheng Jiang
2020-11-10 9:34 ` Maxime Coquelin
@ 2020-11-11 9:08 ` Cheng Jiang
2020-11-12 16:53 ` Maxime Coquelin
2020-11-13 8:40 ` Maxime Coquelin
1 sibling, 2 replies; 6+ messages in thread
From: Cheng Jiang @ 2020-11-11 9:08 UTC (permalink / raw)
To: maxime.coquelin, chenbo.xia; +Cc: dev, patrick.fu, YvonneX.Yang, Cheng Jiang
Add checking return value of string split function to fix the
coverity issue.
Fixes: 3a04ecb21420 ("examples/vhost: add async vhost args parsing")
Coverity issue: 363739
Signed-off-by: Cheng Jiang <Cheng1.jiang@intel.com>
---
v2: checked args_nr explicitly
examples/vhost/ioat.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/examples/vhost/ioat.c b/examples/vhost/ioat.c
index b2c74f6537..720c0b0b81 100644
--- a/examples/vhost/ioat.c
+++ b/examples/vhost/ioat.c
@@ -36,7 +36,7 @@ open_ioat(const char *value)
int ret = 0;
uint16_t i = 0;
char *dma_arg[MAX_VHOST_DEVICE];
- uint8_t args_nr;
+ int args_nr;
while (isblank(*addrs))
addrs++;
@@ -54,9 +54,18 @@ open_ioat(const char *value)
}
args_nr = rte_strsplit(substr, strlen(substr),
dma_arg, MAX_VHOST_DEVICE, ',');
- do {
+ if (args_nr <= 0) {
+ ret = -1;
+ goto out;
+ }
+ while (i < args_nr) {
char *arg_temp = dma_arg[i];
- rte_strsplit(arg_temp, strlen(arg_temp), ptrs, 2, '@');
+ uint8_t sub_nr;
+ sub_nr = rte_strsplit(arg_temp, strlen(arg_temp), ptrs, 2, '@');
+ if (sub_nr != 2) {
+ ret = -1;
+ goto out;
+ }
start = strstr(ptrs[0], "txd");
if (start == NULL) {
@@ -105,7 +114,7 @@ open_ioat(const char *value)
dma_info->nr++;
i++;
- } while (i < args_nr);
+ }
out:
free(input);
return ret;
--
2.29.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH v2] examples/vhost: fix string split error handling issue
2020-11-11 9:08 ` [dpdk-dev] [PATCH v2] " Cheng Jiang
@ 2020-11-12 16:53 ` Maxime Coquelin
2020-11-13 8:40 ` Maxime Coquelin
1 sibling, 0 replies; 6+ messages in thread
From: Maxime Coquelin @ 2020-11-12 16:53 UTC (permalink / raw)
To: Cheng Jiang, chenbo.xia; +Cc: dev, patrick.fu, YvonneX.Yang
On 11/11/20 10:08 AM, Cheng Jiang wrote:
> Add checking return value of string split function to fix the
> coverity issue.
>
> Fixes: 3a04ecb21420 ("examples/vhost: add async vhost args parsing")
> Coverity issue: 363739
>
> Signed-off-by: Cheng Jiang <Cheng1.jiang@intel.com>
> ---
> v2: checked args_nr explicitly
>
> examples/vhost/ioat.c | 17 +++++++++++++----
> 1 file changed, 13 insertions(+), 4 deletions(-)
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Thanks,
Maxime
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH v2] examples/vhost: fix string split error handling issue
2020-11-11 9:08 ` [dpdk-dev] [PATCH v2] " Cheng Jiang
2020-11-12 16:53 ` Maxime Coquelin
@ 2020-11-13 8:40 ` Maxime Coquelin
1 sibling, 0 replies; 6+ messages in thread
From: Maxime Coquelin @ 2020-11-13 8:40 UTC (permalink / raw)
To: Cheng Jiang, chenbo.xia; +Cc: dev, patrick.fu, YvonneX.Yang
On 11/11/20 10:08 AM, Cheng Jiang wrote:
> Add checking return value of string split function to fix the
> coverity issue.
>
> Fixes: 3a04ecb21420 ("examples/vhost: add async vhost args parsing")
> Coverity issue: 363739
>
> Signed-off-by: Cheng Jiang <Cheng1.jiang@intel.com>
> ---
> v2: checked args_nr explicitly
>
> examples/vhost/ioat.c | 17 +++++++++++++----
> 1 file changed, 13 insertions(+), 4 deletions(-)
Applied to dpdk-next-virtio/main.
Thanks,
Maxime
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-11-13 8:41 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-06 3:23 [dpdk-dev] [PATCH v1] examples/vhost: fix string split error handling issue Cheng Jiang
2020-11-10 9:34 ` Maxime Coquelin
2020-11-11 0:58 ` Jiang, Cheng1
2020-11-11 9:08 ` [dpdk-dev] [PATCH v2] " Cheng Jiang
2020-11-12 16:53 ` Maxime Coquelin
2020-11-13 8:40 ` Maxime Coquelin
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).