unpack bug?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I have some code developed on a linux system with PHP 5.1.6, its using the PEAR Net_DNS class to send dns updates, part of this requires unpacking a binary string, an example is below.

This works on PHP 5.1.6 but fails on 5.2.8, it appears that it may be in relation to the following change in 5.2.4 "Added missing format validator to unpack()".

A test case of the code is as follows:

$data = base64_decode("A86pgAAAAAAAAAABCHJuZGMta2V5AAD6AP8AAAAAADoIaG1hYy1tZDUHc2lnLWFsZwNyZWcDaW50AAAASW8kgAEsABBd7hm4xnUjl5kWLXfbZKaBA84AAAAA");
$offset=58;
$d = unpack('\@$offset/nth/Ntl/nfudge/nmac_size', $data);
print_r($d);

Expected output:
Array
(
   [th] => 974
   [tl] => -1451229184
   [fudge] => 0
   [mac_size] => 0
)
Actual output:
Warning: unpack(): Invalid format type \

Removing the "\" before that @ does make the error go away but causes a different result:

Array
(
   [th] => 52905
   [tl] => -2147483648
   [fudge] => 0
   [mac_size] => 0
)

Is this being caused by the format validator and if so should it be allowing this, or is there another way I can unpack this correctly.

Regards

James



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux