]> granicus.if.org Git - apache/commitdiff
parse byteranges correctly using the new apr_strtoff function
authorAndré Malo <nd@apache.org>
Tue, 25 May 2004 19:09:45 +0000 (19:09 +0000)
committerAndré Malo <nd@apache.org>
Tue, 25 May 2004 19:09:45 +0000 (19:09 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@103765 13f79535-47bb-0310-9956-ffa450edef68

modules/http/http_protocol.c

index a8ffa871734e1e342f79bac1de8f9045c7f099e3..7020018bd64e8eb1832642a16b4e0ceea85e4d41 100644 (file)
@@ -2788,6 +2788,8 @@ static int parse_byterange(char *range, apr_off_t clength,
                            apr_off_t *start, apr_off_t *end)
 {
     char *dash = strchr(range, '-');
+    char *errp;
+    apr_off_t number;
 
     if (!dash) {
         return 0;
@@ -2795,15 +2797,23 @@ static int parse_byterange(char *range, apr_off_t clength,
 
     if ((dash == range)) {
         /* In the form "-5" */
-        *start = clength - apr_atoi64(dash + 1);
+        if (apr_strtoff(&number, dash+1, &errp, 10) || *errp) {
+            return 0;
+        }
+        *start = clength - number;
         *end = clength - 1;
     }
     else {
-        *dash = '\0';
-        dash++;
-        *start = apr_atoi64(range);
+        *dash++ = '\0';
+        if (apr_strtoff(&number, range, &errp, 10) || *errp) {
+            return 0;
+        }
+        *start = number;
         if (*dash) {
-            *end = apr_atoi64(dash);
+            if (apr_strtoff(&number, dash, &errp, 10) || *errp) {
+                return 0;
+            }
+            *end = number;
         }
         else {                  /* "5-" */
             *end = clength - 1;