[PHP-CVS] cvs: php-src(PHP_5_2) / NEWS /ext/standard pack.c /ext/standard/tests/strings bug38770.phpt

2009-05-12 Thread Ilia Alshanetsky
iliaa   Tue May 12 12:35:45 2009 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/ext/standard/tests/strings bug38770.phpt 
/php-src/ext/standard   pack.c 
/php-srcNEWS 
  Log:
  
  MFB: Fixed bug #47564 (unpacking unsigned long 32bit bit endian returns
  wrong result)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/bug38770.phpt?r1=1.1.2.1r2=1.1.2.2diff_format=u
Index: php-src/ext/standard/tests/strings/bug38770.phpt
diff -u php-src/ext/standard/tests/strings/bug38770.phpt:1.1.2.1 
php-src/ext/standard/tests/strings/bug38770.phpt:1.1.2.2
--- php-src/ext/standard/tests/strings/bug38770.phpt:1.1.2.1Sun Nov 19 
18:20:48 2006
+++ php-src/ext/standard/tests/strings/bug38770.phptTue May 12 12:35:45 2009
@@ -12,7 +12,7 @@
 --EXPECT-- 
 Array
 (
-[1] = -3
+[1] = 4294937296
 )
 Array
 (
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/pack.c?r1=1.57.2.5.2.8r2=1.57.2.5.2.9diff_format=u
Index: php-src/ext/standard/pack.c
diff -u php-src/ext/standard/pack.c:1.57.2.5.2.8 
php-src/ext/standard/pack.c:1.57.2.5.2.9
--- php-src/ext/standard/pack.c:1.57.2.5.2.8Wed Dec 31 11:17:45 2008
+++ php-src/ext/standard/pack.c Tue May 12 12:35:45 2009
@@ -15,7 +15,7 @@
| Author: Chris Schneider cschn...@relog.ch  |
+--+
  */
-/* $Id: pack.c,v 1.57.2.5.2.8 2008/12/31 11:17:45 sebastian Exp $ */
+/* $Id: pack.c,v 1.57.2.5.2.9 2009/05/12 12:35:45 iliaa Exp $ */
 
 #include php.h
 
@@ -799,6 +799,13 @@
}
 
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;
}
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.1498r2=1.2027.2.547.2.1499diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.1498 php-src/NEWS:1.2027.2.547.2.1499
--- php-src/NEWS:1.2027.2.547.2.1498Mon May 11 12:35:00 2009
+++ php-src/NEWSTue May 12 12:35:45 2009
@@ -62,6 +62,8 @@
   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)



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



[PHP-CVS] cvs: php-src(PHP_5_2) / NEWS /ext/standard pack.c /ext/standard/tests/strings bug38770.phpt

2006-11-19 Thread Ilia Alshanetsky
iliaa   Sun Nov 19 18:20:48 2006 UTC

  Added files: (Branch: PHP_5_2)
/php-src/ext/standard/tests/strings bug38770.phpt 

  Modified files:  
/php-srcNEWS 
/php-src/ext/standard   pack.c 
  Log:
  Fixed bug #38770 (unpack() broken with longs on 64 bit machines).
  
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.367r2=1.2027.2.547.2.368diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.367 php-src/NEWS:1.2027.2.547.2.368
--- php-src/NEWS:1.2027.2.547.2.367 Fri Nov 17 11:40:52 2006
+++ php-src/NEWSSun Nov 19 18:20:48 2006
@@ -74,6 +74,8 @@
   (Dmitry)
 - Fixed bug #39090 (DirectoryFilterDots doxygen docs and example is wrong).
   (Marcus)
+- Fixed bug #38770 (unpack() broken with longs on 64 bit machines). (Ilia,
+  David Soria Parra).
 - Fixed bug #38698 (for some keys cdbmake creates corrupted db and cdb can't 
   read valid db). (Marcus)
 - Fixed bug #38680 (Added missing handling of basic types in json_decode).
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/pack.c?r1=1.57.2.5r2=1.57.2.5.2.1diff_format=u
Index: php-src/ext/standard/pack.c
diff -u php-src/ext/standard/pack.c:1.57.2.5 
php-src/ext/standard/pack.c:1.57.2.5.2.1
--- php-src/ext/standard/pack.c:1.57.2.5Sun Feb 26 10:49:50 2006
+++ php-src/ext/standard/pack.c Sun Nov 19 18:20:48 2006
@@ -15,7 +15,7 @@
| Author: Chris Schneider [EMAIL PROTECTED]  |
+--+
  */
-/* $Id: pack.c,v 1.57.2.5 2006/02/26 10:49:50 helly Exp $ */
+/* $Id: pack.c,v 1.57.2.5.2.1 2006/11/19 18:20:48 iliaa Exp $ */
 
 #include php.h
 
@@ -753,14 +753,16 @@
 
case 'i': 
case 'I': {
-   long v;
+   long v = 0;
int issigned = 0;
 
if (type == 'i') {
issigned = 
input[inputpos + (machine_little_endian ? (sizeof(int) - 1) : 0)]  0x80;
-   }
+   } else if (sizeof(long)  4  
(input[inputpos + machine_endian_long_map[3]]  0x80) == 0x80) {
+   v = ~INT_MAX;
+}
 
-   v = 
php_unpack(input[inputpos], sizeof(int), issigned, int_map);
+   v |= 
php_unpack(input[inputpos], sizeof(int), issigned, int_map);
add_assoc_long(return_value, n, 
v);
break;
}
@@ -771,7 +773,7 @@
case 'V': {
int issigned = 0;
int *map = 
machine_endian_long_map;
-   long v;
+   long v = 0;
 
if (type == 'l') {
issigned = 
input[inputpos + (machine_little_endian ? 3 : 0)]  0x80;
@@ -781,7 +783,11 @@
map = 
little_endian_long_map;
}
 
-   v = 
php_unpack(input[inputpos], 4, issigned, map);
+   if (sizeof(long)  4  
(input[inputpos + machine_endian_long_map[3]]  0x80) == 0x80) {
+   v = ~INT_MAX;
+   }
+
+   v |= 
php_unpack(input[inputpos], 4, issigned, map);
add_assoc_long(return_value, n, 
v);
break;
}

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/bug38770.phpt?view=markuprev=1.1
Index: php-src/ext/standard/tests/strings/bug38770.phpt
+++ php-src/ext/standard/tests/strings/bug38770.phpt

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