Handling of out of bound byte ranges

This commit is contained in:
Veloman Yunkan 2020-05-22 16:46:38 +04:00
parent 1a99bacfe3
commit 0a30a77c08
1 changed files with 3 additions and 2 deletions

View File

@ -41,9 +41,10 @@ bool is_compressible_mime_type(const std::string& mimeType)
int get_range_len(const kiwix::Entry& entry, RequestContext::ByteRange range)
{
const int entrySize = entry.getSize();
return range.second == -1
? entry.getSize() - range.first
: range.second - range.first + 1;
? entrySize - range.first
: std::min(range.second + 1, entrySize) - range.first;
}
} // unnamed namespace