httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mathihalli, Madhusudan" <mad...@hp.com>
Subject RE: [PATCH] RE: Regarding parse_byterange()
Date Wed, 12 May 2004 22:08:14 GMT

>-----Original Message-----
>From: Joe Orton [mailto:jorton@redhat.com] 
>Sent: Friday, April 30, 2004 3:08 AM
>
>Looks fine, though it doesn't handle errors in apr_atoi64 
>itself so it would be good to surround the calls with a single 
>errno = 0 / ... / 
>if (errno) return -1; check too.
>

It seems like I didn't follow up on this mail :(

I don't like the idea of application programs setting the value of
'errno' to zero.
However, if that's the correct method - then I don't have much choice :)
Here's the new patch - if I don't hear any objections, I'll go ahead and
commit it.

-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     12 May 2004 22:03:36 -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,17 @@
     else {
         *dash = '\0';
         dash++;
-        *start = apr_atoi64(range);
+
+        errno = 0;
+        val = apr_atoi64(range);
+        if ((errno != 0) || ((*start = val) != val)) {
+            return -1;
+        }
         if (*dash) {
-            *end = apr_atoi64(dash);
+            val = apr_atoi64(dash);
+            if ((errno != 0) || ((*end = val) != val)) {
+                return -1;
+            }
         }
         else {                  /* "5-" */
             *end = clength - 1;

Mime
View raw message