From 93122af01f75eebd6a66c34f172a30209bb3f6cb Mon Sep 17 00:00:00 2001 From: Alex Reid Date: Wed, 18 Jan 2023 11:36:24 +0000 Subject: [PATCH] Ensure we exactly match cfgstring prefix against 'tcm-user' Signed-off-by: Alex Reid --- libtcmu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libtcmu.c b/libtcmu.c index 8ed7c2ac..f9421025 100644 --- a/libtcmu.c +++ b/libtcmu.c @@ -439,9 +439,10 @@ static bool device_parse_cfg(struct tcmu_device *dev, /* Check valid cfgstring */ oldptr = cfgstring; ptr = strchr(oldptr, '/'); + len = ptr-oldptr; if (!ptr) goto err_badcfg; - if (strncmp(cfgstring, "tcm-user", ptr-oldptr)) + if (strncmp(cfgstring, "tcm-user", len) || cfgstring[len] != '/') goto err_badcfg; /* Get HBA name */