cvs: php-src /main SAPI.c

From: Date: Tue, 06 Dec 2005 03:39:27 +0000
Subject: cvs: php-src /main SAPI.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-35733@lists.php.net to get a copy of this message
iliaa Mon Dec 5 22:39:27 2005 EDT Modified files: /php-src/main SAPI.c Log: Prevent header injection by limiting each header to a single line. http://cvs.php.net/diff.php/php-src/main/SAPI.c?r1=1.207&r2=1.208&ty=u Index: php-src/main/SAPI.c diff -u php-src/main/SAPI.c:1.207 php-src/main/SAPI.c:1.208 --- php-src/main/SAPI.c:1.207 Sun Nov 6 17:07:12 2005 +++ php-src/main/SAPI.c Mon Dec 5 22:39:26 2005 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: SAPI.c,v 1.207 2005/11/06 22:07:12 sniper Exp $ */ +/* $Id: SAPI.c,v 1.208 2005/12/06 03:39:26 iliaa Exp $ */ #include <ctype.h> #include <sys/stat.h> @@ -588,6 +588,19 @@ while(isspace(header_line[header_line_len-1])) header_line[--header_line_len]='\0'; + /* new line safety check */ + { + char *s = header_line, *e = header_line + header_line_len, *p; + while (s < e && (p = memchr(s, '\n', (e - s)))) { + if (*(p + 1) == ' ' || *(p + 1) == '\t') { + s = p + 1; + continue; + } + efree(header_line); + sapi_module.sapi_error(E_WARNING, "Header may not contain more then a single header, new line detected."); + return FAILURE; + } + } sapi_header.header = header_line; sapi_header.header_len = header_line_len;

« previous php.cvs (#35733) next »