From e439020961cedb8c665f7c143f9275a3e7309b5a Mon Sep 17 00:00:00 2001 From: Ziye Yang Date: Fri, 24 Mar 2017 11:27:43 +0800 Subject: [PATCH] vhost: check the strlen of basename Change-Id: I0f0eb7edbec71609754a4cda80c578b75c84c87f Signed-off-by: Ziye Yang --- lib/vhost/vhost.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index 0f3fd0de4..476927105 100644 --- a/lib/vhost/vhost.c +++ b/lib/vhost/vhost.c @@ -1127,10 +1127,11 @@ spdk_vhost_startup(void *arg1, void *arg2) pthread_t tid; const char *basename = arg1; - if (basename) { + if (basename && strlen(basename) > 0) { ret = snprintf(dev_dirname, sizeof(dev_dirname) - 2, "%s", basename); - if ((size_t)ret >= sizeof(dev_dirname) - 2) + if ((size_t)ret >= sizeof(dev_dirname) - 2) { rte_exit(EXIT_FAILURE, "Char dev dir path length %d is too long\n", ret); + } if (dev_dirname[ret - 1] != '/') { dev_dirname[ret] = '/';