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

jiangg jiangg at mail.ustc.edu.cn
Sun Apr 16 13:39:40 CEST 2017


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

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

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));
-- 
2.7.4




More information about the dev mailing list