php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14684 pack doesn't correctly handle zero integer values
Submitted: 2001-12-24 05:09 UTC Modified: 2001-12-24 07:08 UTC
From: someone at records dot ru Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 4.1.0 OS: Linux 2.2.18
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: someone at records dot ru
New email:
PHP Version: OS:

 

 [2001-12-24 05:09 UTC] someone at records dot ru
<?= pack("L",0); ?>

On PHP 4.1.0, compiled as Apache shared module outputs string "\x20\x20\x20\x20" (4 spaces). It is not "L"-specific issue. <?= pack("C",0); ?> also outputs "\x20".
Any non-zero values are processed OK.
PHP 4.0.1pl2 and 4.0.6 seems to work correctly.

Configuration includes --with-apxs, --with-mysql (bundled), --with-bz2, --without-xml and --without-pear.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-24 05:34 UTC] someone at records dot ru
I've just compiled CGI version, it works fine, output is "\x00\x00\x00\x00".

Also here's my configure string from phpinfo:
'./configure' '--with-apxs=/www/bin/apxs' '--with-mod_charset' '--without-pear' '--with-zlib' '--with-bz2' '--with-mysql=/usr' '--disable-xml'

make CFLAGS="-DHAVE_MYSQL_MYSQL_H -I/www/include"

 [2001-12-24 05:48 UTC] mfischer@php.net
There's nothing wrong with pack, neither CGI nor apache. I guess your client can't handle this.

You can verify this youself with:

<?
    $foo = pack('L', 0);

    $f = fopen('/tmp/pack', 'wb');
    fwrite($f, $foo);
    fclose($f);
?>

$ hexdump /tmp/pack
0000000 0000 0000
0000004

As you can see, it's perfectly valid (tested with apache, mod_php).


 [2001-12-24 06:31 UTC] someone at records dot ru
OK, this works. But:

# echo '<?=pack("L",0)?>' > /home/russiansubmitter.com/db/pack.php

# nc -o dump 127.0.0.1 80
GET /db/pack.php HTTP/1.0
Host: russiansubmitter.com

HTTP/1.1 200 OK
Date: Mon, 24 Dec 2001 11:27:07 GMT
Server: Apache/1.3.20 (Unix) PHP/4.1.0 rus/PL30.5
X-Powered-By: PHP/4.1.0
Connection: close
Content-Type: text/html; charset=windows-1251
Expires: Thu, 01 Jan 1970 00:00:01 GMT
Last-Modified: Mon, 24 Dec 2001 11:27:14 GMT

    #
^^^^ (4 spaces here)

# cat dump

> 00000000 47 45 54 20 2f 64 62 2f 70 61 63 6b 2e 70 68 70 # GET /db/pack.php
> 00000010 20 48 54 54 50 2f 31 2e 30 0a                   #  HTTP/1.0.
> 0000001a 48 6f 73 74 3a 20 72 75 73 73 69 61 6e 73 75 62 # Host: russiansub
> 0000002a 6d 69 74 74 65 72 2e 63 6f 6d 0a                # mitter.com.
> 00000035 0a                                              # .
< 00000000 48 54 54 50 2f 31 2e 31 20 32 30 30 20 4f 4b 0d # HTTP/1.1 200 OK.
< 00000010 0a 44 61 74 65 3a 20 4d 6f 6e 2c 20 32 34 20 44 # .Date: Mon, 24 D
< 00000020 65 63 20 32 30 30 31 20 31 31 3a 32 37 3a 30 37 # ec 2001 11:27:07
< 00000030 20 47 4d 54 0d 0a 53 65 72 76 65 72 3a 20 41 70 #  GMT..Server: Ap
< 00000040 61 63 68 65 2f 31 2e 33 2e 32 30 20 28 55 6e 69 # ache/1.3.20 (Uni
< 00000050 78 29 20 50 48 50 2f 34 2e 31 2e 30 20 72 75 73 # x) PHP/4.1.0 rus
< 00000060 2f 50 4c 33 30 2e 35 0d 0a 58 2d 50 6f 77 65 72 # /PL30.5..X-Power
< 00000070 65 64 2d 42 79 3a 20 50 48 50 2f 34 2e 31 2e 30 # ed-By: PHP/4.1.0
< 00000080 0d 0a 43 6f 6e 6e 65 63 74 69 6f 6e 3a 20 63 6c # ..Connection: cl
< 00000090 6f 73 65 0d 0a 43 6f 6e 74 65 6e 74 2d 54 79 70 # ose..Content-Typ
< 000000a0 65 3a 20 74 65 78 74 2f 68 74 6d 6c 3b 20 63 68 # e: text/html; ch
< 000000b0 61 72 73 65 74 3d 77 69 6e 64 6f 77 73 2d 31 32 # arset=windows-12
< 000000c0 35 31 0d 0a 45 78 70 69 72 65 73 3a 20 54 68 75 # 51..Expires: Thu
< 000000d0 2c 20 30 31 20 4a 61 6e 20 31 39 37 30 20 30 30 # , 01 Jan 1970 00
< 000000e0 3a 30 30 3a 30 31 20 47 4d 54 0d 0a 4c 61 73 74 # :00:01 GMT..Last
< 000000f0 2d 4d 6f 64 69 66 69 65 64 3a 20 4d 6f 6e 2c 20 # -Modified: Mon,
< 00000100 32 34 20 44 65 63 20 32 30 30 31 20 31 31 3a 32 # 24 Dec 2001 11:2
< 00000110 37 3a 31 34 20 47 4d 54 0d 0a 0d 0a 20 20 20 20 # 7:14 GMT....

4 last bytes are "\x20\x20\x20\x20"
Here i've used 'plain' client that cannot affect traffic. Maybe this IS apache bug?
 [2001-12-24 07:08 UTC] someone at records dot ru
Problem solved after header('Content-Type: application/octet-stream') was added. Seems like apache configuration problem. Sorry for bogus report and thank for you time.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 15:01:33 2024 UTC