Skip to content

Commit

Permalink
http.c: sanity-check for number of newlines in headers
Browse files Browse the repository at this point in the history
Reported by:	clang19 scan-build
  • Loading branch information
gperciva committed Nov 26, 2024
1 parent 2884f38 commit 8aa3dbc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions http/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,12 @@ gotheaders(struct http_cookie * H, uint8_t * buf, size_t buflen)
H->res_headlen - bufpos);
}

/*
* We only call gotheaders() if we've found "\r\n\r\n", so we must have
* at least two EOLs.
*/
assert(H->res.nheaders >= 2);

/* # headers = # lines - 1 (status-line) - 1 (blank line). */
H->res.nheaders -= 2;

Expand Down

0 comments on commit 8aa3dbc

Please sign in to comment.