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

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

index 375ebe42d0ced4b249b5c3b04ce907487d936755..4d12c75ac311a08beb9f682ca9161c82d912cabf 100644 (file)
@@ -784,6 +784,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
 (