Skip to content
Permalink
Browse files Browse the repository at this point in the history
Merge pull request #15930 from nmeum/pr/uri_parser_scheme
uri_parser: check if uri is long enough to even contain a ://
  • Loading branch information
cgundogan committed Feb 5, 2021
2 parents 89922e8 + 333572e commit 07f1254
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sys/uri_parser/uri_parser.c
Expand Up @@ -55,7 +55,7 @@ static char *_consume_scheme(uri_parser_result_t *result, char *uri,
result->scheme_len = p - uri;

/* check if authority part exists '://' */
if ((p[1] != '\0') && (p[2] != '\0') && (p[1] == '/') && (p[2] == '/')) {
if (((uri_end - p) > 2) && (p[1] == '/') && (p[2] == '/')) {
*has_authority = true;
/* skip '://' */
return p + 3;
Expand Down
11 changes: 11 additions & 0 deletions tests/unittests/tests-uri_parser/tests-uri_parser.c
Expand Up @@ -401,6 +401,17 @@ static const validate_t validate_uris[] = {
"./this:that",
"",
0),
VEC("pP://",
true,
"pP",
"",
"",
"",
"",
"",
"",
"",
0),
};

static char _failure_msg[VEC_MSG_LEN];
Expand Down

0 comments on commit 07f1254

Please sign in to comment.