Skip to content

Commit

Permalink
Ensure we exactly match cfgstring prefix against 'tcm-user'
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Reid committed Jan 18, 2023
1 parent 09e9f20 commit 9611e40
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libtcmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ static bool device_parse_cfg(struct tcmu_device *dev,
const char *dev_name, const char *cfgstring)
{
int len;
int cfgstrlen;
const char *ptr, *oldptr;

len = snprintf(dev->dev_name, sizeof(dev->dev_name), "%s", dev_name);
Expand All @@ -439,9 +440,10 @@ static bool device_parse_cfg(struct tcmu_device *dev,
/* Check valid cfgstring */
oldptr = cfgstring;
ptr = strchr(oldptr, '/');
cfgstrlen = ptr-oldptr;
if (!ptr)
goto err_badcfg;
if (strncmp(cfgstring, "tcm-user", ptr-oldptr))
if (strncmp(cfgstring, "tcm-user", cfgstrlen) || cfgstring[cfgstrlen] != '/')
goto err_badcfg;

/* Get HBA name */
Expand Down

0 comments on commit 9611e40

Please sign in to comment.