mirror of https://github.com/kiwix/libkiwix.git
Handling of out of bound byte ranges
This commit is contained in:
parent
1a99bacfe3
commit
0a30a77c08
|
@ -41,9 +41,10 @@ bool is_compressible_mime_type(const std::string& mimeType)
|
||||||
|
|
||||||
int get_range_len(const kiwix::Entry& entry, RequestContext::ByteRange range)
|
int get_range_len(const kiwix::Entry& entry, RequestContext::ByteRange range)
|
||||||
{
|
{
|
||||||
|
const int entrySize = entry.getSize();
|
||||||
return range.second == -1
|
return range.second == -1
|
||||||
? entry.getSize() - range.first
|
? entrySize - range.first
|
||||||
: range.second - range.first + 1;
|
: std::min(range.second + 1, entrySize) - range.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // unnamed namespace
|
} // unnamed namespace
|
||||||
|
|
Loading…
Reference in New Issue