mirror of
https://github.com/kiwix/kiwix-tools.git
synced 2025-09-22 11:22:38 -04:00
Merge pull request #98 from kiwix/http_byte_range_fix
Fix HTTP request byte range handling #91
This commit is contained in:
commit
1fcc1ad9d4
@ -676,9 +676,12 @@ static int accessHandlerCallback(void* cls,
|
|||||||
int range_start = 0;
|
int range_start = 0;
|
||||||
int range_end = -1;
|
int range_end = -1;
|
||||||
if (acceptRangeHeaderValue != NULL) {
|
if (acceptRangeHeaderValue != NULL) {
|
||||||
|
// [FIXME] This part is sub-optimal and potentially prone to fail
|
||||||
|
// because we don't check the string length before using substr
|
||||||
|
// The `range.length() >= 6` should mitigate the bug but we have to
|
||||||
|
// rewrite this part.
|
||||||
auto range = std::string(acceptRangeHeaderValue);
|
auto range = std::string(acceptRangeHeaderValue);
|
||||||
if (range.substr(0, 6) == "bytes=")
|
if (range.length() >= 6 && range.substr(0, 6) == "bytes=") {
|
||||||
{
|
|
||||||
range = range.substr(6);
|
range = range.substr(6);
|
||||||
std::istringstream iss(range);
|
std::istringstream iss(range);
|
||||||
iss >> range_start;
|
iss >> range_start;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user