Skip to content

Commit 9611e40

Browse files
author
Alex Reid
committed
Ensure we exactly match cfgstring prefix against 'tcm-user'
1 parent 09e9f20 commit 9611e40

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

libtcmu.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ static bool device_parse_cfg(struct tcmu_device *dev,
428428
const char *dev_name, const char *cfgstring)
429429
{
430430
int len;
431+
int cfgstrlen;
431432
const char *ptr, *oldptr;
432433

433434
len = snprintf(dev->dev_name, sizeof(dev->dev_name), "%s", dev_name);
@@ -439,9 +440,10 @@ static bool device_parse_cfg(struct tcmu_device *dev,
439440
/* Check valid cfgstring */
440441
oldptr = cfgstring;
441442
ptr = strchr(oldptr, '/');
443+
cfgstrlen = ptr-oldptr;
442444
if (!ptr)
443445
goto err_badcfg;
444-
if (strncmp(cfgstring, "tcm-user", ptr-oldptr))
446+
if (strncmp(cfgstring, "tcm-user", cfgstrlen) || cfgstring[cfgstrlen] != '/')
445447
goto err_badcfg;
446448

447449
/* Get HBA name */

0 commit comments

Comments
 (0)