From c2a9245d2589d235eacefbea5029fb1bea003c21 Mon Sep 17 00:00:00 2001 From: Bryan Duxbury Date: Tue, 12 May 2009 16:44:52 +0000 Subject: [PATCH] THRIFT-499. php: Thrift_protocol PHP extension does not handle signedness correctly Cast all the number types to signed values before making PHP longs out of them. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@773974 13f79535-47bb-0310-9956-ffa450edef68 --- lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp b/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp index 399cbe62..76a8a440 100644 --- a/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp +++ b/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp @@ -441,23 +441,23 @@ void binary_deserialize(int8_t thrift_typeID, PHPInputTransport& transport, zval case T_BYTE: { uint8_t c; transport.readBytes(&c, 1); - RETURN_LONG(c); + RETURN_LONG((int8_t)c); } case T_I16: { uint16_t c; transport.readBytes(&c, 2); - RETURN_LONG(ntohs(c)); + RETURN_LONG((int16_t)ntohs(c)); } case T_I32: { uint32_t c; transport.readBytes(&c, 4); - RETURN_LONG(ntohl(c)); + RETURN_LONG((int32_t)ntohl(c)); } case T_U64: case T_I64: { uint64_t c; transport.readBytes(&c, 8); - RETURN_LONG(ntohll(c)); + RETURN_LONG((int64_t)ntohll(c)); } case T_DOUBLE: { union { -- 2.17.1