Fix corner case in processing server response

* src/http.c (response_head_terminator): Don't access uninitialized data
* fuzz/wget_read_hunk_fuzzer.c: Sync response_head_terminator()
This commit is contained in:
Tim Rühsen 2019-03-25 16:05:47 +01:00
parent 4046cd2a71
commit 5d87635c66
2 changed files with 2 additions and 2 deletions

View File

@ -170,7 +170,7 @@ response_head_terminator (const char *start, const char *peeked, int peeklen)
return p + 2;
}
/* p==end-2: check for \n\n directly preceding END. */
if (p[0] == '\n' && p[1] == '\n')
if (peeklen >= 2 && p[0] == '\n' && p[1] == '\n')
return p + 2;
return NULL;

View File

@ -553,7 +553,7 @@ response_head_terminator (const char *start, const char *peeked, int peeklen)
return p + 2;
}
/* p==end-2: check for \n\n directly preceding END. */
if (p[0] == '\n' && p[1] == '\n')
if (peeklen >= 2 && p[0] == '\n' && p[1] == '\n')
return p + 2;
return NULL;