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] = '/';