Re: [PATCH] For Bug #38770
| From: | David Soria Parra | Date: | Fri, 17 Nov 2006 17:56:37 +0000 |
| Subject: | Re: [PATCH] For Bug #38770 | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-26663@lists.php.net to get a copy of this message | ||
I also attached the patch against PHP_5_2 CVS
Index: ext/standard/pack.c
===================================================================
RCS file: /repository/php-src/ext/standard/pack.c,v
retrieving revision 1.57.2.5
diff -u -r1.57.2.5 pack.c
--- ext/standard/pack.c 26 Feb 2006 10:49:50 -0000 1.57.2.5
+++ ext/standard/pack.c 17 Nov 2006 17:54:24 -0000
@@ -756,11 +756,15 @@
long v;
int issigned = 0;
- if (type == 'i') {
issigned = input[inputpos +
(machine_little_endian ? (sizeof(int) - 1) : 0)] & 0x80;
+
+ if (sizeof(long) > sizeof(int) &&
issigned) {
+ v = ~INT_MAX;
+ } else {
+ v = 0;
}
- v = php_unpack(&input[inputpos], sizeof(int),
issigned, int_map);
+ v |= php_unpack(&input[inputpos], sizeof(int),
(type=='i')?issigned:0, int_map);
add_assoc_long(return_value, n, v);
break;
}
@@ -781,7 +785,14 @@
map = little_endian_long_map;
}
- v = php_unpack(&input[inputpos], 4, issigned,
map);
+ if (sizeof(long) > 4 && (input[inputpos +
map[3]] & 0x80) == 0x80) {
+ v = ~INT_MAX;
+ } else {
+ v = 0;
+ }
+
+ v |= php_unpack(&input[inputpos], 4, issigned,
map);
+
add_assoc_long(return_value, n, v);
break;
}