]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Correctly parse Range headers with multiple ranges
authorRuediger Pluem <rpluem@apache.org>
Thu, 2 Oct 2025 13:00:44 +0000 (13:00 +0000)
committerRuediger Pluem <rpluem@apache.org>
Thu, 2 Oct 2025 13:00:44 +0000 (13:00 +0000)
Correctly parse Range headers with multiple ranges that have
whitespaces around the comma separating the ranges from each other by
trimming the whitespace.

PR: 69831

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1928901 13f79535-47bb-0310-9956-ffa450edef68

changes-entries/pr69831.txt [new file with mode: 0644]
modules/http/byterange_filter.c

diff --git a/changes-entries/pr69831.txt b/changes-entries/pr69831.txt
new file mode 100644 (file)
index 0000000..8e254fa
--- /dev/null
@@ -0,0 +1,3 @@
+  *) http: Correctly parse Range headers with multiple ranges that have
+     whitespaces around the comma separating the ranges from each other.
+     PR 69831 [Ruediger Pluem]
index 6fdc66588783979df8ba46e27099fb0ab26cfde2..e1c69b0ba71e499608ee409d6ee55c97b766e2d7 100644 (file)
@@ -136,9 +136,17 @@ static int ap_set_byterange(request_rec *r, apr_off_t clength,
     }
     *indexes = apr_array_make(r->pool, ranges, sizeof(indexes_t));
     while ((cur = ap_getword(r->pool, &range, ','))) {
-        char *dash;
+        char *dash, *end_cur;
         apr_off_t number, start, end;
 
+         /* Remove leading and trailing white spaces */
+        while (apr_isspace(*cur))
+            ++cur;
+        /* blast trailing whitespace */
+        end_cur = &cur[strlen(cur)];
+        while (--end_cur >= cur && apr_isspace(*end_cur))
+            *end_cur = '\0';
+
         if (!*cur)
             break;