Skip to content

Commit 518c651

Browse files
committed
Avoid pointer UB in strip_header
Don't calculate header_start if lc_header_start is NULL, as we're going to overflow the address space in that case.
1 parent 265af40 commit 518c651

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

ext/standard/http_fopen_wrapper.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,10 @@ static inline void strip_header(char *header_bag, char *lc_header_bag,
8686
const char *lc_header_name)
8787
{
8888
char *lc_header_start = strstr(lc_header_bag, lc_header_name);
89-
char *header_start = header_bag + (lc_header_start - lc_header_bag);
90-
9189
if (lc_header_start
9290
&& (lc_header_start == lc_header_bag || *(lc_header_start-1) == '\n')
9391
) {
92+
char *header_start = header_bag + (lc_header_start - lc_header_bag);
9493
char *lc_eol = strchr(lc_header_start, '\n');
9594
char *eol = header_start + (lc_eol - lc_header_start);
9695

0 commit comments

Comments
 (0)