mirror of
https://github.com/curl/curl.git
synced 2025-03-25 15:50:32 +08:00
tool_cb_hdr: add an additional parsing check
- Don't dereference the past-the-end element when parsing the server's Content-disposition header. As 'p' is advanced it can point to the past-the-end element and prior to this change 'p' could be dereferenced in that case. Technically the past-the-end element is not out of bounds because dynbuf (which manages the header line) automatically adds a null terminator to every buffer and that is not included in the buffer length passed to the header callback. Closes https://github.com/curl/curl/pull/12320
This commit is contained in:
parent
50bf253357
commit
efbbbf4f7a
@ -150,16 +150,19 @@ size_t tool_header_cb(char *ptr, size_t size, size_t nmemb, void *userdata)
|
||||
char *filename;
|
||||
size_t len;
|
||||
|
||||
while(*p && (p < end) && !ISALPHA(*p))
|
||||
while((p < end) && *p && !ISALPHA(*p))
|
||||
p++;
|
||||
if(p > end - 9)
|
||||
break;
|
||||
|
||||
if(memcmp(p, "filename=", 9)) {
|
||||
/* no match, find next parameter */
|
||||
while((p < end) && (*p != ';'))
|
||||
while((p < end) && *p && (*p != ';'))
|
||||
p++;
|
||||
continue;
|
||||
if((p < end) && *p)
|
||||
continue;
|
||||
else
|
||||
break;
|
||||
}
|
||||
p += 9;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user