httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Jagielski <...@jaguNET.com>
Subject Re: PR 6973 / 1.3.15 showstopper
Date Sat, 16 Dec 2000 11:58:23 GMT
I'll review a bit deeper, but at 1st blush this looks at least
better than what we currently have :)

William A. Rowe, Jr. wrote:
> 
> Oops... small typos, sorry.  Try this on for size, instead.
> 
> -----Original Message-----
> From: William A. Rowe, Jr. [mailto:wrowe@rowe-clan.net]
> Sent: Friday, December 15, 2000 11:48 PM
> To: new-httpd@apache.org
> Subject: RE: PR 6973 / 1.3.15 showstopper
> 
> 
> 
> Ok... based on our conjecture that #<sp>-<sp># is absolutely 
> invalid, and that
> someday we will do things the 'right way' - here is the patch - 
> sort of back
> to where I was two days ago.  Note, especially, that this can 
> be easily cleaned
> up for the new behavior, the #ifdef's are temporary things.
> 
> 
> static int parse_byterange(char *range, long clength, long 
> *start, long *end)
> {
>     char *off, *off2;
>     long lead, tail;
>     
>     /* Look for leading dash */
>     while (ap_isspace(*range)) 
>         ++range;
>     if (*(range) == '-')
>         off = range + 1;
>     else if (ap_isdigit(*range)) {
>         /* Parse first value */
>         lead = strtol(range, &off, 10);
> 
>         /* Skip dash */
>         if (*(off) != '-') /* Dash is -required- */
> #ifdef TERNIARY_BYTERANGE
>             return -1;
> #else
>             return 0;
> #endif
>         ++off;
>     }
> #ifdef TERNIARY_BYTERANGE
>     else if (*range)
>         return -1;  /* Dash was -required- */
> #endif
>     else
>         return 0;  /* Empty is syntactically valid */
> 
>     /* Parse second value */
>     if (ap_isdigit(*off))
>         tail = strtol(off, &off2, 10);
>     else
>         off2 = off;
>     
>     /* Confirm end of segment */
>     while (ap_isspace(*off2)) 
>         ++off2;
>     if (*off2) /* nothing else is valid */
> #ifdef TERNIARY_BYTERANGE
>         return -1;
> #else
>         return 0;
> #endif
> 
>     if (*range == '-')
>     {
>         /* format was "-5" */
>         *start = clength - tail;
>         *end = clength - 1;
> 
> #ifdef TERNIARY_BYTERANGE
>         if (tail < 1)
>             return -1;
> #endif
> 
>         if (*start < 0)  /* Correct "-5" longer than clength */
>             *start = 0;
>     }
>     else {
>         *start = lead;
>         if (!ap_isdigit(*off))  /* format was "5-" */
>             *end = clength - 1;
>         else {                  /* format was "5-9" */
>             *end = tail;
> #ifdef TERNIARY_BYTERANGE
>             if (*start > *end)  /* "9-5" is invalid */
>                 return -1;
> #endif
>             if (*end >= clength) /* End of "5-9" is past clength */
>                 *end = clength - 1;
>         }
>     }
> 
>     /* This is a more general test; catch effectively empty responses */
>     if (*start > *end)
>         return 0;
> 
>     return 1;
> }
> 
> 
> 
> 


-- 
===========================================================================
   Jim Jagielski   [|]   jim@jaguNET.com   [|]   http://www.jaguNET.com/
          "Casanova will have many weapons; To beat him you will
              have to have more than forks and flatulence."

Mime
View raw message