|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-03-25 03:33 UTC] helly@php.net
[2004-03-25 03:38 UTC] helly@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 15:00:01 2025 UTC |
Description: ------------ There is a bug in the sapi_header_op() function in main/sapi.c (referencing the 5.0.0RC1 line numbers). In the special case for the Content-Type header starting on line 560 is this code: size_t len = header_line_len - (ptr - header_line), newlen; while (*ptr == ' ' && *ptr != '\0') { ptr++; } The mistake is in calculating the len based on the location of ptr, but then adjusting ptr up to shorten the string to remove leading spaces without also adjusting len down. The len variable ends up being one character too long for each space removed from between the colon and the content type. This extra space propagates through and ends up causing random extra characters on the end of the Content-Type line in the output headers (one for each space skipped). Suggested patch: --- sapi.c.orig Wed Mar 24 23:07:58 2004 +++ sapi.c Wed Mar 24 23:08:04 2004 @@ -562,6 +562,7 @@ size_t len = header_line_len - (ptr - header_line), newlen; while (*ptr == ' ' && *ptr != '\0') { ptr++; + len--; } #if HAVE_ZLIB if(!strncmp(ptr, "image/", sizeof("image/")-1)) { Reproduce code: --------------- <?php header("Content-Type: text/plain"); ?> Expected result: ---------------- The Content-Type header delivered with my default character set attached ("utf-8"): Content-Type: text/plain;charset=utf-8 Actual result: -------------- Becuase the length is overstated by one, there is an extra character attached to the end of the Content-Type header. Running IIS CGI this character is an ascii-Z and IIS reports "not all headers returned."