ID:               42510
 Comment by:       shodan at shodan dot ru
 Reported By:      jr-php2 at quo dot to
 Status:           Assigned
 Bug Type:         Strings related
 Operating System: Linux x86-64
 PHP Version:      5.2.4
 Assigned To:      iliaa
 New Comment:

This bug also happens with unpack("N") with PHP versions 5.2.2 to 5.2.5
on x64 systems:

[EMAIL PROTECTED] tmp]$ cat 1.php
<?php

$s = "\x8a\x4a\xef\x23";
list(,$i) = unpack ( "N*", $s );
var_dump($i);

?>
[EMAIL PROTECTED] tmp]$ ~/bin/php525 1.php
int(-1974800605)

Note that it did not happen on 5.1.x series:

[EMAIL PROTECTED] tmp]$ php 1.php
int(2320166691)
[EMAIL PROTECTED] tmp]$ php --version
PHP 5.1.6 (cli) (built: Jun 17 2007 11:37:40)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
[EMAIL PROTECTED] tmp]$


Previous Comments:
------------------------------------------------------------------------

[2007-09-04 10:43:41] [EMAIL PROTECTED]

Assigned to Ilia who fixed bug #38770



------------------------------------------------------------------------

[2007-09-03 16:39:46] jr-php2 at quo dot to

> Are you actually using PHP 5.2.4?

Yes.

> (the bug you claim to be bogus was fixed already in 5.2.1..

Maybe I wasn't clear: I'm suggesting that the bug report *and* the fix
that went into 5.2.1 are bogus.

Result with PHP 5.2.0 (matches my "expected result"):

unpack = 3368601800
ip2long = 3368601800

Result with PHP 5.2.1-5.2.4:

unpack = -926365496
ip2long = 3368601800

> why didn't you report it earlier?!)

I didn't notice the problem until now.

------------------------------------------------------------------------

[2007-09-03 08:14:48] [EMAIL PROTECTED]

Are you actually using PHP 5.2.4? (the bug you claim to be bogus was
fixed already in 5.2.1..why didn't you report it earlier?!)

------------------------------------------------------------------------

[2007-09-02 20:06:52] jr-php2 at quo dot to

Digging deeper, it looks like 'V' and 'N' used to work as documented
until bug #38770 was "fixed in CVS".

Isn't #38770 a bogus report, though? Since 'N' is documented as being
unsigned, isn't the user wrong to expect it to return a negative result?

------------------------------------------------------------------------

[2007-09-01 20:33:57] jr-php2 at quo dot to

Okay, looking at the unpack() code, it appears that:

- 'l' and 'L' are both treated as signed, even though 'l' is documented
as signed and 'L' is documented as unsigned.

- 'N' and 'V' are treated as signed, even though both are documented as
unsigned.

So who's right here, the code or the documentation?

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/42510

-- 
Edit this bug report at http://bugs.php.net/?id=42510&edit=1

Reply via email to