Skip to content

Commit

Permalink
Fix '-b' option parsing
Browse files Browse the repository at this point in the history
fix null pointer and empty string handling

The previous behavor is infinite loop

examples:
"" empty string
"vendor:for,model:bar," invalid options, please note the comma at the end

Signed-off-by: Syrone Wong <[email protected]>
  • Loading branch information
wongsyrone committed May 5, 2020
1 parent 2614566 commit 4d05c81
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions wsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,14 @@ int set_getresp(const char *str, const char **next)
const char *p, *val;
size_t keylen, vallen;

if (str == NULL) {
return -1;
}

if (*str == '\0') {
return -1;
}

/* Trim leading space. */
while (*str && isspace(*str))
str++;
Expand Down

0 comments on commit 4d05c81

Please sign in to comment.