fix a crash with mod_proxy if the Host: header is empty.

From lighttpd Trac
This commit is contained in:
brad 2006-01-03 23:39:11 +00:00
parent 275b321055
commit 4e3349d0be
2 changed files with 19 additions and 1 deletions

View File

@ -1,10 +1,11 @@
# $OpenBSD: Makefile,v 1.25 2005/11/23 15:22:48 brad Exp $
# $OpenBSD: Makefile,v 1.26 2006/01/03 23:39:11 brad Exp $
SHARED_ONLY= Yes
COMMENT= "secure, fast, compliant, and very flexible web-server"
DISTNAME= lighttpd-1.4.8
PKGNAME= ${DISTNAME}p1
CATEGORIES= www net
MAINTAINER= Brad Smith <brad@openbsd.org>

View File

@ -0,0 +1,17 @@
$OpenBSD: patch-src_mod_proxy_c,v 1.1 2006/01/03 23:39:12 brad Exp $
--- src/mod_proxy.c.orig Tue Jan 3 18:18:34 2006
+++ src/mod_proxy.c Tue Jan 3 18:20:03 2006
@@ -439,7 +439,12 @@ static int proxy_create_env(server *srv,
BUFFER_APPEND_STRING_CONST(b, " HTTP/1.0\r\n");
proxy_append_header(con, "X-Forwarded-For", (char *)inet_ntop_cache_get_ip(srv, &(con->dst_addr)));
- proxy_set_header(con, "X-Host", con->request.http_host->ptr);
+ /* http_host is NOT is just a pointer to a buffer
+ * which is NULL if it is not set */
+ if (con->request.http_host &&
+ !buffer_is_empty(con->request.http_host)) {
+ proxy_set_header(con, "X-Host", con->request.http_host->ptr);
+ }
proxy_set_header(con, "X-Forwarded-Proto", con->conf.is_ssl ? "https" : "http");
/* request header */