[dpdk-dev] examples/vhost: fix the use of strnlen()

Message ID 1492342780-3810-1-git-send-email-jiangg@mail.ustc.edu.cn (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

jiangg April 16, 2017, 11:39 a.m. UTC
  The return value of strnlen(s, maxlen) is never bigger than maxlen.

Signed-off-by: jiangg <jiangg@mail.ustc.edu.cn>
---
 examples/vhost/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Thomas Monjalon May 5, 2017, 12:11 p.m. UTC | #1
Hi,

16/04/2017 13:39, jiangg:
> The return value of strnlen(s, maxlen) is never bigger than maxlen.
> 
> Signed-off-by: jiangg <jiangg@mail.ustc.edu.cn>

Please, could you provide your full name in SoB?

We could also add a Fixes: line.

Thanks
  
jiangg May 5, 2017, 1:59 p.m. UTC | #2
My name is Gang Jiang.


> -----原始邮件-----

> 发件人: "Thomas Monjalon" <thomas@monjalon.net>

> 发送时间: 2017-05-05 20:11:35 (星期五)

> 收件人: jiangg <jiangg@mail.ustc.edu.cn>

> 抄送: dev@dpdk.org

> 主题: Re: [dpdk-dev] [PATCH] examples/vhost: fix the use of strnlen()

> 

> Hi,

> 

> 16/04/2017 13:39, jiangg:

> > The return value of strnlen(s, maxlen) is never bigger than maxlen.

> > 

> > Signed-off-by: jiangg <jiangg@mail.ustc.edu.cn>

> 

> Please, could you provide your full name in SoB?

> 

> We could also add a Fixes: line.

> 

> Thanks
  
Thomas Monjalon May 10, 2017, 5:06 p.m. UTC | #3
05/05/2017 15:59, Gang Jiang:
> My name is Gang Jiang.
> 
> 发件人: "Thomas Monjalon" <thomas@monjalon.net>
> > 16/04/2017 13:39, jiangg:
> > > The return value of strnlen(s, maxlen) is never bigger than maxlen.
> > > 
> > > Signed-off-by: jiangg <jiangg@mail.ustc.edu.cn>
> > 
> > Please, could you provide your full name in SoB?
> > 
> > We could also add a Fixes: line.
> > 
> > Thanks

Fixes: 4796ad63ba1f ("examples/vhost: import userspace vhost application")

Applied, thanks
  

Patch

diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index aa88733..e07f866 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -396,7 +396,7 @@  static int
 us_vhost_parse_socket_path(const char *q_arg)
 {
 	/* parse number string */
-	if (strnlen(q_arg, PATH_MAX) > PATH_MAX)
+	if (strnlen(q_arg, PATH_MAX) == PATH_MAX)
 		return -1;
 
 	socket_files = realloc(socket_files, PATH_MAX * (nb_sockets + 1));