Skip to content

Commit

Permalink
tfw_http_search_cookie() may pass chunk == end, which is past the last
Browse files Browse the repository at this point in the history
chunk, to tfw_str_collect_cmp(). Firstly check chunk == end in
tfw_str_collect_cmp() and only after than make an assertion that chunk
is a plain string.
  • Loading branch information
krizhanovsky committed Aug 17, 2022
1 parent a1e0aed commit ec72714
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 2 additions & 0 deletions fw/http_match.c
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,7 @@ tfw_http_search_cookie(const char *cstr, unsigned long clen,
TfwStr *chunk, *end;
TfwStr tmp = { 0 };
unsigned int n = cookie->nchunks;

/* Search cookie name. */
end = cookie->chunks + cookie->nchunks;
for (chunk = cookie->chunks; chunk != end; ++chunk, --n) {
Expand Down Expand Up @@ -951,6 +952,7 @@ tfw_http_search_cookie(const char *cstr, unsigned long clen,
}

} else {
WARN_ON_ONCE(1);
continue;
}
/*
Expand Down
3 changes: 1 addition & 2 deletions fw/str.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,12 +561,11 @@ void tfw_str_collect_cmp(TfwStr *chunk, TfwStr *end, TfwStr *out,
{
TfwStr *next;

BUG_ON(!TFW_STR_PLAIN(chunk));

if (unlikely(chunk == end)) {
bzero_fast(out, sizeof(*out));
return;
}
BUG_ON(!TFW_STR_PLAIN(chunk));

/* If this is last chunk, just return it in this case. */
next = chunk + 1;
Expand Down

0 comments on commit ec72714

Please sign in to comment.