Skip to content

Commit

Permalink
Merge branch '5.3' into 5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
cataphract committed Apr 23, 2012
2 parents 883d406 + 8d748e5 commit 485638a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
6 changes: 2 additions & 4 deletions ext/standard/pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -758,16 +758,14 @@ PHP_FUNCTION(unpack)

case 'i':
case 'I': {
long v = 0;
long v;
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;
}
Expand Down
6 changes: 1 addition & 5 deletions ext/standard/tests/strings/bug38770.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
--FILE--
<?php

foreach (array('N','I','l') as $v) {
foreach (array('N','l') as $v) {
print_r(unpack($v, pack($v, -30000)));
}

Expand All @@ -22,8 +22,4 @@ Array
(
[1] => -30000
)
Array
(
[1] => -30000
)
Done
15 changes: 15 additions & 0 deletions ext/standard/tests/strings/bug61764.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
Bug #61764: 'I' unpacks n as signed if n > 2^31-1 on LP64
--SKIPIF--
<?php
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
--FILE--
<?php
//expected -30000 mod 2^32 = 4294937296, and not -30000
//because we can represent 4294937296 with our PHP int type
print_r(unpack('I', pack('L', -30000)));
--EXPECT--
Array
(
[1] => 4294937296
)

0 comments on commit 485638a

Please sign in to comment.