Allow HTTP range past EOF

Fixes #683
This commit is contained in:
Justine Tunney 2022-11-07 05:52:24 -08:00
parent 52f1db7220
commit 4de2cf34e6
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
2 changed files with 20 additions and 5 deletions

View file

@ -77,8 +77,11 @@ bool ParseHttpRange(const char *p, size_t n, long resourcelength,
if (n) return false;
if (start < 0) return false;
if (length < 1) return false;
if (start > resourcelength) return false;
if (__builtin_add_overflow(start, length, &ending)) return false;
if (ending > resourcelength) return false;
if (ending > resourcelength) {
length = resourcelength - start;
}
*out_start = start;
*out_length = length;
return true;