- 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
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;