Bug #920 Updated: printf will not echo out NULL byte
| From: | Bug Database | Date: | Sun, 15 Nov 1998 07:24:24 +0000 |
| Subject: | Bug #920 Updated: printf will not echo out NULL byte | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-2411@lists.php.net to get a copy of this message | ||
ID: 920
User Update by: jordy@wserv.com
Status: Open
Bug Type: Misbehaving function
Description: printf will not echo out NULL byte
This should print out a NULL byte to the web browser, however it doesn't print anything. The
same code in C and Perl will print a NULL byte out to the web browser. This is required to implement
special protocols which require NULL bytes to be sent out.
# cat test.php3
<?php
printf("%c", 0);
?>
# socket -v localhost 80 > output
connected to localhost port 80 (http)
GET /test.php3 HTTP/1.0
# cat -A output
HTTP/1.1 200 OK^M$
Date: Sun, 15 Nov 1998 07:18:42 GMT^M$
Server: Apache/1.3.2 (Unix) PHP/3.0.4 FrontPage/3.0.4.2 mod_ssl/2.0.11 SSLeay/0.9.0b^M$
Connection: close^M$
Content-Type: text/html^M$
^M$
# cat test.pl
#!/usr/bin/perl
print "Content-type: text/html\n\n";
printf("%c", 0);
# socket -v localhost 80 > output
connected to localhost port 80 (http)
GET /test.pl HTTP/1.0
# cat -A output
HTTP/1.1 200 OK^M$
Date: Sun, 15 Nov 1998 07:19:53 GMT^M$
Server: Apache/1.3.2 (Unix) PHP/3.0.4 FrontPage/3.0.4.2 mod_ssl/2.0.11 SSLeay/0.9.0b^M$
Connection: close^M$
Content-Type: text/html^M$
^M$
^@
Note the ^@ at the end.. it is the NULL which the PERL script prints, but the PHP script does not.
echo() does not have this same problem:
# cat test.php3
<?php
echo chr(0);
?>
# socket -v localhost 80 > output
connected to localhost port 80 (http)
GET /test.php3 HTTP/1.0
# cat -A output
HTTP/1.1 200 OK^M$
Date: Sun, 15 Nov 1998 07:23:02 GMT^M$
Server: Apache/1.3.2 (Unix) PHP/3.0.4 FrontPage/3.0.4.2 mod_ssl/2.0.11 SSLeay/0.9.0b^M$
Connection: close^M$
Content-Type: text/html^M$
^M$
^@
Full Bug description available at: http://ca.php.net/bugs.php3?id=920
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net