mirror of
https://github.com/curl/curl.git
synced 2025-09-17 09:32:48 +03:00
headers_push: error out if a folded header has no previous header
As that would indicate an illegal header. The fuzzer reached the assert
in unfold_value() proving that this case can happen.
Follow-up to c9b60f0053
Closes #8939
This commit is contained in:
parent
83ee5c428d
commit
b7baa78451
|
@ -293,9 +293,14 @@ CURLcode Curl_headers_push(struct Curl_easy *data, const char *header,
|
|||
}
|
||||
hlen = end - header + 1;
|
||||
|
||||
if((header[0] == ' ') || (header[0] == '\t'))
|
||||
/* line folding, append value to the previous header's value */
|
||||
return unfold_value(data, header, hlen);
|
||||
if((header[0] == ' ') || (header[0] == '\t')) {
|
||||
if(data->state.prevhead)
|
||||
/* line folding, append value to the previous header's value */
|
||||
return unfold_value(data, header, hlen);
|
||||
else
|
||||
/* can't unfold without a previous header */
|
||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||
}
|
||||
|
||||
hs = calloc(1, sizeof(*hs) + hlen);
|
||||
if(!hs)
|
||||
|
|
Loading…
Reference in New Issue
Block a user