diff options
author | Armen Baghumian <abaghumian@noggin.com.au> | 2015-12-04 03:05:42 +0000 |
---|---|---|
committer | Armen Baghumian <abaghumian@noggin.com.au> | 2015-12-05 23:32:35 +0000 |
commit | 77fbdd28e2dc0d86e17f1c0a245cae6cb3392f76 (patch) | |
tree | bc34eaf598d4281d8f60d4e680c2a6157ba9949c /php | |
parent | fe2f8d32aa7ffb23baf5989a208477189cc98f99 (diff) | |
download | flatbuffers-77fbdd28e2dc0d86e17f1c0a245cae6cb3392f76.tar.gz flatbuffers-77fbdd28e2dc0d86e17f1c0a245cae6cb3392f76.tar.bz2 flatbuffers-77fbdd28e2dc0d86e17f1c0a245cae6cb3392f76.zip |
Correct the max/min signed/unsigned 32-bit int
The test was trying to pack an unsigned int which couldn't fit as a
signed int and putInt() wasn't doing the validation in the correct range
Diffstat (limited to 'php')
-rw-r--r-- | php/ByteBuffer.php | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/php/ByteBuffer.php b/php/ByteBuffer.php index 4a583b7a..cd6af76a 100644 --- a/php/ByteBuffer.php +++ b/php/ByteBuffer.php @@ -239,7 +239,9 @@ class ByteBuffer */ public function putInt($offset, $value) { - self::validateValue(~PHP_INT_MAX, PHP_INT_MAX, $value, "int"); + // 2147483647 = (1 << 31) -1 = Maximum signed 32-bit int + // -2147483648 = -1 << 31 = Minimum signed 32-bit int + self::validateValue(-2147483648, 2147483647, $value, "int"); $this->assertOffsetAndLength($offset, 4); $this->writeLittleEndian($offset, 4, $value); @@ -252,7 +254,8 @@ class ByteBuffer public function putUint($offset, $value) { // NOTE: We can't put big integer value. this is PHP limitation. - self::validateValue(0, PHP_INT_MAX, $value, "uint", " php has big numbers limitation. check your PHP_INT_MAX"); + // 4294967295 = (1 << 32) -1 = Maximum unsigned 32-bin int + self::validateValue(0, 4294967295, $value, "uint", " php has big numbers limitation. check your PHP_INT_MAX"); $this->assertOffsetAndLength($offset, 4); $this->writeLittleEndian($offset, 4, $value); |