1 diff -Nrup thttpd-2.25b.orig/libhttpd.c thttpd-2.25b/libhttpd.c
2 --- thttpd-2.25b.orig/libhttpd.c 2003-12-25 19:06:05.000000000 +0000
3 +++ thttpd-2.25b/libhttpd.c 2007-01-08 21:43:28.000000000 +0000
4 @@ -1469,7 +1469,7 @@ expand_symlinks( char* path, char** rest
5 httpd_realloc_str( &checked, &maxchecked, checkedlen );
6 (void) strcpy( checked, path );
7 /* Trim trailing slashes. */
8 - while ( checked[checkedlen - 1] == '/' )
9 + while ( checkedlen && checked[checkedlen - 1] == '/' )
11 checked[checkedlen - 1] = '\0';
13 @@ -1488,7 +1488,7 @@ expand_symlinks( char* path, char** rest
14 restlen = strlen( path );
15 httpd_realloc_str( &rest, &maxrest, restlen );
16 (void) strcpy( rest, path );
17 - if ( rest[restlen - 1] == '/' )
18 + if ( restlen && rest[restlen - 1] == '/' )
19 rest[--restlen] = '\0'; /* trim trailing slash */
21 /* Remove any leading slashes. */