[packages/php-pecl-msgpack] Rel 2. Fix 32bit build
arekm
arekm at pld-linux.org
Fri Oct 23 16:48:29 CEST 2026
commit 8e1a8860283625fa910788d3f1630658bfe2e054
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Fri Oct 23 16:32:27 2026 +0200
Rel 2. Fix 32bit build
php-pecl-msgpack.spec | 4 +++-
unserialize-crash-hardening.patch | 34 +---------------------------------
unserialize-uint64-32bit.patch | 17 +++++++++++++++++
3 files changed, 21 insertions(+), 34 deletions(-)
---
diff --git a/php-pecl-msgpack.spec b/php-pecl-msgpack.spec
index c596cf4..5dfedaa 100644
--- a/php-pecl-msgpack.spec
+++ b/php-pecl-msgpack.spec
@@ -10,13 +10,14 @@ Summary: PHP extension for interfacing with MessagePack
Name: %{php_name}-pecl-%{modname}
# For PHP < 7, see 0.5.x branch
Version: 3.0.1
-Release: 1
+Release: 2
License: PHP 3.01
Group: Development/Languages/PHP
Source0: https://pecl.php.net/get/%{modname}-%{version}.tgz
# Source0-md5: d7cd8f5be5c30fe9a993d60fa985a7d8
Patch0: enum-unserialize-segfault.patch
Patch1: unserialize-crash-hardening.patch
+Patch2: unserialize-uint64-32bit.patch
URL: https://pecl.php.net/package/msgpack/
BuildRequires: %{php_name}-devel >= 4:7.0.0
BuildRequires: rpmbuild(macros) >= 1.666
@@ -53,6 +54,7 @@ These are the files needed to compile programs using MessagePack.
mv %{modname}-%{version}/* .
%patch -P0 -p1
%patch -P1 -p1
+%patch -P2 -p1
# https://github.com/msgpack/msgpack-php/issues/110 (these self-skip on php >= 7.1)
rm tests/040*.phpt
diff --git a/unserialize-crash-hardening.patch b/unserialize-crash-hardening.patch
index b158233..db96666 100644
--- a/unserialize-crash-hardening.patch
+++ b/unserialize-crash-hardening.patch
@@ -1,40 +1,8 @@
Reject malformed unserialize input instead of crashing: a custom-object or enum
record whose payload is not a string, and an object back-reference whose index is
not an integer, were used without a type check; a back-reference that points at the
-container being built freed it before the copy. msgpack_unserialize() with a template
-dereferenced a null HashTable when data for an array/object property was a scalar or
-shorter than the template.
+container being built freed it before the copy.
-diff --git a/msgpack_convert.c b/msgpack_convert.c
-index 1f90ef4..3e4148c 100644
---- a/msgpack_convert.c
-+++ b/msgpack_convert.c
-@@ -27,6 +27,13 @@ static inline int msgpack_convert_long_to_properties(HashTable *ht, zval *object
- HashTable *dataht;
- dataht = HASH_OF(val);
-
-+ if (dataht == NULL) {
-+ MSGPACK_WARNING("[msgpack] (%s) "
-+ "data for an array property is not an array",
-+ __FUNCTION__);
-+ return FAILURE;
-+ }
-+
- if ((dataval = zend_hash_index_find(dataht, prop_key_index)) == NULL) {
- MSGPACK_WARNING("[msgpack] (%s) "
- "can't get data value by index",
-@@ -401,7 +408,10 @@ int msgpack_convert_object(zval *return_value, zval *tpl, zval *value) /* {{{ */
-
- num_key = 0;
- ZEND_HASH_FOREACH_STR_KEY_VAL(ret, str_key, data) {
-- aryval = zend_hash_index_find(ht, num_key);
-+ if ((aryval = zend_hash_index_find(ht, num_key)) == NULL) {
-+ MSGPACK_WARNING("[msgpack] (%s) can't get data value by index", __FUNCTION__);
-+ return FAILURE;
-+ }
-
- if (data == NULL) {
- MSGPACK_WARNING("[msgpack] (%s) can't get data value by index", __FUNCTION__);
diff --git a/msgpack_unpack.c b/msgpack_unpack.c
index df33d7b..ad5bc0a 100644
--- a/msgpack_unpack.c
diff --git a/unserialize-uint64-32bit.patch b/unserialize-uint64-32bit.patch
new file mode 100644
index 0000000..a1bd7b1
--- /dev/null
+++ b/unserialize-uint64-32bit.patch
@@ -0,0 +1,17 @@
+Fix uint64 unserialization of values in (ZEND_LONG_MAX, 2^52] on 32-bit (x32):
+1L is a 32-bit long there, so "1L<<52" overflows to 0 and the value is emitted
+as a numeric string instead of a double. The comparison is against a uint64_t.
+
+diff --git a/msgpack_unpack.c b/msgpack_unpack.c
+index ad5bc0a..74fe23c 100644
+--- a/msgpack_unpack.c
++++ b/msgpack_unpack.c
+@@ -427,7 +427,7 @@ int msgpack_unserialize_uint64(msgpack_unpack_data *unpack, uint64_t data, zval
+
+ if (data <= (uint64_t) ZEND_LONG_MAX) {
+ ZVAL_LONG(*obj, data);
+- } else if (data <= 1L<<52) {
++ } else if (data <= 1ULL<<52) {
+ ZVAL_DOUBLE(*obj, data);
+ } else {
+ char buf[0x20] = {0}, *ptr = print_u64_to_buf(&buf[sizeof(buf)-1], data);
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/php-pecl-msgpack.git/commitdiff/8e1a8860283625fa910788d3f1630658bfe2e054
More information about the pld-cvs-commit
mailing list