freebsd-ports/www/thttpd/files/patch-libhttpd.c
Alexey Dokuchaev a6de0a3f68 - Update to version 2.26 and cleanup MASTER_SITES; define LICENSE
- Change default WWW root from ${PREFIX}/www/data to more expected (and
  standard) ${WWWDIR} (${PREFIX}/www/thttpd) and default CGI pattern to
  "/cgi-bin/*" since this goes better in line with default installation
- Enable IPREAL option by default (do not convert it to unconditional
  patch as it could lead to privacy violation, which might be unwanted)
- Change served data default MIME type to "application/octet-stream"
- Rename thttpdpasswd(1) and its manpage to thtpasswd(1); this not just
  makes it shorter, but is more consistent with what popular GNU/Linux
  distributions do
- Stop generating index pages for directories by default for security
  reasons, provide an option for that
- Properly stagify port by patching upstream makefiles instead of doing
  entire installation by hand (and thus retire `do-install' target)
- Adjust and sort pkg-plist in accordance with the the above changes
2015-01-18 13:37:34 +00:00

62 lines
2 KiB
C

--- libhttpd.c.orig Mon May 27 01:22:26 2002
+++ libhttpd.c Sun Oct 20 23:49:58 2002
@@ -1483,7 +1483,7 @@
httpd_realloc_str( &checked, &maxchecked, checkedlen );
(void) strcpy( checked, path );
/* Trim trailing slashes. */
- while ( checked[checkedlen - 1] == '/' )
+ while ( checkedlen && checked[checkedlen - 1] == '/' )
{
checked[checkedlen - 1] = '\0';
--checkedlen;
@@ -1502,7 +1502,7 @@
restlen = strlen( path );
httpd_realloc_str( &rest, &maxrest, restlen );
(void) strcpy( rest, path );
- if ( rest[restlen - 1] == '/' )
+ if ( restlen && rest[restlen - 1] == '/' )
rest[--restlen] = '\0'; /* trim trailing slash */
if ( ! tildemapped )
/* Remove any leading slashes. */
@@ -2348,8 +2348,11 @@
{
int i;
i = strlen( hc->origfilename ) - strlen( hc->pathinfo );
- if ( i > 0 && strcmp( &hc->origfilename[i], hc->pathinfo ) == 0 )
- hc->origfilename[i - 1] = '\0';
+ if ( strcmp( &hc->origfilename[i], hc->pathinfo ) == 0 )
+ {
+ if ( i == 0 ) hc->origfilename[0] = '\0';
+ else hc->origfilename[i - 1] = '\0';
+ }
}
/* If the expanded filename is an absolute path, check that it's still
@@ -2571,7 +2574,7 @@
size_t ext_len, encodings_len;
int i, top, bot, mid;
int r;
- char* default_type = "text/plain; charset=%s";
+ char* default_type = "application/octet-stream";
/* Peel off encoding extensions until there aren't any more. */
n_me_indexes = 0;
@@ -3312,7 +3315,7 @@
cp += strcspn( cp, " \t" );
status = atoi( cp );
}
- if ( ( cp = strstr( headers, "Location:" ) ) != (char*) 0 &&
+ else if ( ( cp = strstr( headers, "Location:" ) ) != (char*) 0 &&
cp < br &&
( cp == headers || *(cp-1) == '\012' ) )
status = 302;
@@ -3889,6 +3892,9 @@
httpd_send_err( hc, 500, err500title, "", err500form, hc->encodedurl );
return -1;
}
+#ifdef USE_SENDFILE
+ hc->file_fd = *((int *) hc->file_address);
+#endif
send_mime(
hc, 200, ok200title, hc->encodings, "", hc->type, hc->sb.st_size,
hc->sb.st_mtime );