]> granicus.if.org Git - php/commitdiff
MFB: Fixed bug #47564 (unpacking unsigned long 32bit bit endian returns
authorIlia Alshanetsky <iliaa@php.net>
Tue, 12 May 2009 12:35:45 +0000 (12:35 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Tue, 12 May 2009 12:35:45 +0000 (12:35 +0000)
wrong result)

NEWS
ext/standard/pack.c
ext/standard/tests/strings/bug38770.phpt

diff --git a/NEWS b/NEWS
index d9fbe8eab4bfeea44fcecb057b05e192c18fd7dc..e930b6808f728a18a85754bc30834a5ed2c9af0c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -62,6 +62,8 @@ PHP                                                                        NEWS
   literal). (Ilia)
 - Fixed bug #47616 (curl keeps crashing). (Felipe)
 - Fixed bug #47598 (FILTER_VALIDATE_EMAIL is locale aware). (Ilia)
+- Fixed bug #47564 (unpacking unsigned long 32bit bit endian returns wrong
+  result). (Ilia)
 - Fixed bug #47487 (performance degraded when reading large chunks after fix of
   bug #44607). (Arnaud)
 - Fixed bug #47468 (enable cli|cgi-only extensions for embed sapi). (Jani)
index 5fc472db0a4895ac8a5ddc08388b1b7ebf288cc3..9dd4f47a486bc71082fb4edb6814ed81e090eeed 100644 (file)
@@ -799,6 +799,13 @@ PHP_FUNCTION(unpack)
                                                }
 
                                                v |= php_unpack(&input[inputpos], 4, issigned, map);
+                                               if (sizeof(long) > 4) {
+                                                       if (type == 'l') {
+                                                               v = (signed int) v; 
+                                                       } else {
+                                                               v = (unsigned int) v;
+                                                       }
+                                               }
                                                add_assoc_long(return_value, n, v);
                                                break;
                                        }
index 2494a911bd315deba6fc416417408b2e1091078a..75522ee9d59a9f7fd21de0323ca268da2ce4580e 100644 (file)
@@ -12,7 +12,7 @@ echo "Done\n";
 --EXPECT--     
 Array
 (
-    [1] => -30000
+    [1] => 4294937296
 )
 Array
 (