Skip to content

Commit

Permalink
Fix an out-of-bounds access
Browse files Browse the repository at this point in the history
Issue seen on CheriBSD running on a Morello board
(core dump when running the test suite).
  • Loading branch information
Julien-Elie committed Nov 2, 2023
1 parent 88d493e commit 080646a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/headers.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ bool
IsValidHeaderBody(const char *p)
{
bool emptycontentline = true;
const char *start = p;

/* Not NULL and not empty. */
if (p == NULL || *p == '\0')
Expand All @@ -73,7 +74,7 @@ IsValidHeaderBody(const char *p)
* re-initialize emptycontentline to true. */
emptycontentline = true;
continue;
} else if (p[-1] == '\r') {
} else if (p > start && p[-1] == '\r') {
/* Case of CR not followed by LF (handled at the previous
* if statement). */
return false;
Expand Down

0 comments on commit 080646a

Please sign in to comment.