Add a lighttpd fix from upstream. From Brad.
- Disable mmap by default with mod_compress, if a user truncates a file we are mmapping, reading the truncated area leads to SIGBUS.
This commit is contained in:
parent
9cd31faea4
commit
18e7b066bb
@ -1,11 +1,11 @@
|
||||
# $OpenBSD: Makefile,v 1.94 2012/01/13 23:02:15 sthen Exp $
|
||||
# $OpenBSD: Makefile,v 1.95 2012/03/06 08:23:43 sthen Exp $
|
||||
|
||||
SHARED_ONLY= Yes
|
||||
|
||||
COMMENT= secure, fast, compliant, and very flexible web-server
|
||||
|
||||
DISTNAME= lighttpd-1.4.30
|
||||
REVISION= 0
|
||||
REVISION= 1
|
||||
CATEGORIES= www net
|
||||
MASTER_SITES= http://download.lighttpd.net/lighttpd/releases-1.4.x/
|
||||
|
||||
|
@ -1,10 +1,96 @@
|
||||
$OpenBSD: patch-src_mod_compress_c,v 1.3 2012/01/13 23:02:15 sthen Exp $
|
||||
$OpenBSD: patch-src_mod_compress_c,v 1.4 2012/03/06 08:23:43 sthen Exp $
|
||||
|
||||
Fix handling if etags are disabled but cache-dir is set - may lead to double response.
|
||||
- Fix handling if etags are disabled but cache-dir is set - may lead to double response.
|
||||
- Disable mmap by default (fixes #2391).
|
||||
|
||||
--- src/mod_compress.c.orig Fri Jan 13 16:26:52 2012
|
||||
+++ src/mod_compress.c Fri Jan 13 16:28:29 2012
|
||||
@@ -826,7 +826,7 @@ PHYSICALPATH_FUNC(mod_compress_physical) {
|
||||
--- src/mod_compress.c.orig Sun Feb 26 00:15:43 2012
|
||||
+++ src/mod_compress.c Sun Feb 26 00:15:33 2012
|
||||
@@ -485,7 +485,7 @@ static int deflate_file_to_file(server *srv, connectio
|
||||
return -1;
|
||||
}
|
||||
|
||||
-
|
||||
+#ifdef USE_MMAP
|
||||
if (MAP_FAILED == (start = mmap(NULL, sce->st.st_size, PROT_READ, MAP_SHARED, ifd, 0))) {
|
||||
log_error_write(srv, __FILE__, __LINE__, "sbss", "mmaping", fn, "failed", strerror(errno));
|
||||
|
||||
@@ -499,7 +499,24 @@ static int deflate_file_to_file(server *srv, connectio
|
||||
|
||||
return -1;
|
||||
}
|
||||
+#else
|
||||
+ start = malloc(sce->st.st_size);
|
||||
+ if (NULL == start || sce->st.st_size != read(ifd, start, sce->st.st_size)) {
|
||||
+ log_error_write(srv, __FILE__, __LINE__, "sbss", "reading", fn, "failed", strerror(errno));
|
||||
|
||||
+ close(ofd);
|
||||
+ close(ifd);
|
||||
+ free(start);
|
||||
+
|
||||
+ /* Remove the incomplete cache file, so that later hits aren't served from it */
|
||||
+ if (-1 == unlink(p->ofn->ptr)) {
|
||||
+ log_error_write(srv, __FILE__, __LINE__, "sbss", "unlinking incomplete cachefile", p->ofn, "failed:", strerror(errno));
|
||||
+ }
|
||||
+
|
||||
+ return -1;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
switch(type) {
|
||||
#ifdef USE_ZLIB
|
||||
case HTTP_ACCEPT_ENCODING_GZIP:
|
||||
@@ -530,7 +547,12 @@ static int deflate_file_to_file(server *srv, connectio
|
||||
}
|
||||
}
|
||||
|
||||
+#ifdef USE_MMAP
|
||||
munmap(start, sce->st.st_size);
|
||||
+#else
|
||||
+ free(start);
|
||||
+#endif
|
||||
+
|
||||
close(ofd);
|
||||
close(ifd);
|
||||
|
||||
@@ -571,14 +593,24 @@ static int deflate_file_to_buffer(server *srv, connect
|
||||
return -1;
|
||||
}
|
||||
|
||||
-
|
||||
+#ifdef USE_MMAP
|
||||
if (MAP_FAILED == (start = mmap(NULL, sce->st.st_size, PROT_READ, MAP_SHARED, ifd, 0))) {
|
||||
log_error_write(srv, __FILE__, __LINE__, "sbss", "mmaping", fn, "failed", strerror(errno));
|
||||
|
||||
close(ifd);
|
||||
return -1;
|
||||
}
|
||||
+#else
|
||||
+ start = malloc(sce->st.st_size);
|
||||
+ if (NULL == start || sce->st.st_size != read(ifd, start, sce->st.st_size)) {
|
||||
+ log_error_write(srv, __FILE__, __LINE__, "sbss", "reading", fn, "failed", strerror(errno));
|
||||
|
||||
+ close(ifd);
|
||||
+ free(start);
|
||||
+ return -1;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
switch(type) {
|
||||
#ifdef USE_ZLIB
|
||||
case HTTP_ACCEPT_ENCODING_GZIP:
|
||||
@@ -598,7 +630,11 @@ static int deflate_file_to_buffer(server *srv, connect
|
||||
break;
|
||||
}
|
||||
|
||||
+#ifdef USE_MMAP
|
||||
munmap(start, sce->st.st_size);
|
||||
+#else
|
||||
+ free(start);
|
||||
+#endif
|
||||
close(ifd);
|
||||
|
||||
if (ret != 0) return -1;
|
||||
@@ -826,7 +862,7 @@ PHYSICALPATH_FUNC(mod_compress_physical) {
|
||||
}
|
||||
response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_BUF_LEN(sce->content_type));
|
||||
/* let mod_staticfile handle the cached compressed files, physical path was modified */
|
||||
|
12
www/lighttpd/patches/patch-src_network_backends_h
Normal file
12
www/lighttpd/patches/patch-src_network_backends_h
Normal file
@ -0,0 +1,12 @@
|
||||
$OpenBSD: patch-src_network_backends_h,v 1.3 2012/03/06 08:23:43 sthen Exp $
|
||||
--- src/network_backends.h.orig Sun Feb 26 00:14:14 2012
|
||||
+++ src/network_backends.h Sun Feb 26 00:14:43 2012
|
||||
@@ -31,7 +31,7 @@
|
||||
# include <sys/uio.h>
|
||||
#endif
|
||||
|
||||
-#if defined HAVE_SYS_MMAN_H && defined HAVE_MMAP
|
||||
+#if defined HAVE_SYS_MMAN_H && defined HAVE_MMAP && defined ENABLE_MMAP
|
||||
# define USE_MMAP
|
||||
# include <sys/mman.h>
|
||||
/* NetBSD 1.3.x needs it */
|
Loading…
x
Reference in New Issue
Block a user