common: validate Content-Range resume offset

This commit is contained in:
iuyua9
2026-05-12 18:34:37 +08:00
parent 6767b97448
commit eb025f765e
4 changed files with 23 additions and 2 deletions
+1 -2
View File
@@ -125,10 +125,9 @@ namespace tools
{
// we requested a range, so check if we're getting it, otherwise truncate
bool got_range = false;
const std::string prefix = "bytes=" + std::to_string(offset) + "-";
for (const auto &kv: headers.m_header_info.m_etc_fields)
{
if (kv.first == "Content-Range" && strncmp(kv.second.c_str(), prefix.c_str(), prefix.size()))
if (kv.first == "Content-Range" && tools::content_range_starts_at(kv.second, offset))
{
got_range = true;
break;