httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mathihalli, Madhusudan" <mad...@hp.com>
Subject [PATCH] RE: Regarding parse_byterange()
Date Thu, 29 Apr 2004 16:43:34 GMT

>-----Original Message-----
>From: Joe Orton [mailto:jorton@redhat.com]
[SNIP]
>
>> What if the user really sent a
>> large value for a small file ? Instead of erroring out - 
>thanks to the
>> overflow mechanism, we'll probably end up serving a sane result -
>> Should we leave it that way ?
>
>Oh, good point, yes, it should definitely be fixed then.
>

How about the following patch ?

-Madhu


Index: http_protocol.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/http/http_protocol.c,v
retrieving revision 1.479
diff -u -r1.479 http_protocol.c
--- http_protocol.c     9 Feb 2004 20:29:20 -0000       1.479
+++ http_protocol.c     29 Apr 2004 16:37:04 -0000
@@ -2800,6 +2800,7 @@
 static int parse_byterange(char *range, apr_off_t clength,
                            apr_off_t *start, apr_off_t *end)
 {
+    apr_int64_t val;
     char *dash = strchr(range, '-');
 
     if (!dash) {
@@ -2814,9 +2815,15 @@
     else {
         *dash = '\0';
         dash++;
-        *start = apr_atoi64(range);
+        val = apr_atoi64(range);
+        if ((*start = val) != val) {
+            return -1;
+        }
         if (*dash) {
-            *end = apr_atoi64(dash);
+            val = apr_atoi64(dash);
+            if ((*end = val) != val) {
+                return -1;
+            }
         }
         else {                  /* "5-" */
             *end = clength - 1;

Mime
View raw message