Re: thttpd 2.04 released (fwd)

From: Olaf Seibert (rhialtoat_private)
Date: Thu Aug 20 1998 - 03:39:31 PDT

  • Next message: Chris Wilson: "WebTrends Log Analyzer password grabber"

    Marc Slemko <marcsat_private> forwarded this from Jef Poskanzer <jefat_private>:
    > *** /tmp/,RCSt101alaP   Mon Aug 10 19:09:49 1998
    > --- libhttpd.c  Mon Aug 10 19:09:31 1998
    > ***************
    > *** 975,980 ****
    > --- 975,986 ----
    >       (void) strcpy( rest, path );
    >       if ( rest[restlen - 1] == '/' )
    >         rest[--restlen] = '\0';         /* trim trailing slash */
    > +     /* Remove any leading slashes. */
    > +     while ( rest[0] == '/' )
    > +       {
    > +       (void) strcpy( rest, &(rest[1]) );
    > +       --restlen;
    > +       }
    >       r = rest;
    >       nlinks = 0;
    
    I'm afraid this is incorrect too but in a more subtle manner. You cannot
    use strcpy to copy overlapping strings, as is done here. (Proving this from
    the ISO C standard is left as an exercise for the reader).
    
    Use memmove(rest, &rest[1], restlen+1-1) instead. (+1 to include the \0
    terminator, -1 because we copy a string that's 1 character shorter than
    rest.)
    
    -Olaf.
    --
    ___ Olaf 'Rhialto' Seibert - rhialtoat_private ---- Unauthorized duplication,
    \X/ .kun.nl ---- while sometimes necessary, is never as good as the real thing.
    



    This archive was generated by hypermail 2b30 : Fri Apr 13 2001 - 14:13:20 PDT