From d8b0aef3072649485848655aaeab23ce3834f9c2 Mon Sep 17 00:00:00 2001 From: casey langen Date: Tue, 28 Nov 2017 01:35:51 -0800 Subject: [PATCH] Fixed a bug in HttpServer where the byte range response header's "to" field may be larger than the size. --- src/plugins/server/HttpServer.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugins/server/HttpServer.cpp b/src/plugins/server/HttpServer.cpp index d19d65326..6898f860b 100644 --- a/src/plugins/server/HttpServer.cpp +++ b/src/plugins/server/HttpServer.cpp @@ -175,7 +175,15 @@ static Range* parseRange(IDataStream* file, const char* range) { if (to > from) { result->from = from; - result->to = (to == 0) ? 0 : to - 1; + if (to == 0) { + result->to = 0; + } + else if (to >= size) { + result->to = size - 1; + } + else { + result->to = to - 1; + } } } catch (...) {