Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match exactly against cfgstring #691

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions libtcmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,8 @@ static struct tcmulib_handler *find_handler(struct tcmulib_context *ctx,
len = found_at - cfgstring;

darray_foreach(handler, ctx->handlers) {
if (!strncmp(cfgstring, handler->subtype, len))
/* Ensure we match exactly, not just a prefix match */
if (!strncmp(cfgstring, handler->subtype, len) && handler->subtype[len] == '\0')
return handler;
}

Expand Down Expand Up @@ -438,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 */
Expand Down