diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2005-12-06 03:39:26 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2005-12-06 03:39:26 +0000 |
commit | a4861d1512f8f0e0512963f82640914fb3e4196b (patch) | |
tree | b758790877e833547d55842125f3fce462aa0811 /main | |
parent | 2d789c2366aae76dca75b17634f3fd0de61e1a97 (diff) | |
download | php-git-a4861d1512f8f0e0512963f82640914fb3e4196b.tar.gz |
Prevent header injection by limiting each header to a single line.
Diffstat (limited to 'main')
-rw-r--r-- | main/SAPI.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/main/SAPI.c b/main/SAPI.c index 230d191373..1b78a5bec2 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -588,6 +588,19 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC) 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; |