Commit f1b9b1ac1a5 for php
commit f1b9b1ac1a5609c011122d71e42220e7d5a48930
Author: ushevchenko <u.shevchenko@fobos-nt.ru>
Date: Tue Oct 13 20:18:01 2026 +0300
Fix: SIGN_EXTENSION (#24258)
Problem:
In unpack(), a uint32_t value is implicitly converted to zend_long
for the L, N and V formats. On 32-bit builds values above INT32_MAX
may become negative; the conversion is implementation-defined.
Solution: add an explicit (zend_long) cast. The returned values do not
change on any platform.
Signed-off-by: Uliya Shevchenko <u.shevchenko@fobos-nt.ru>
Signed-off-by: Georgij Tsarin <crystarm@altlinux.org>
diff --git a/ext/standard/pack.c b/ext/standard/pack.c
index 969f5a2db74..3c6bb7c35e2 100644
--- a/ext/standard/pack.c
+++ b/ext/standard/pack.c
@@ -1260,7 +1260,7 @@ PHP_FUNCTION(unpack)
if (type == 'l') {
v = (int32_t) x;
} else {
- v = x;
+ v = (zend_long) x;
}
ZVAL_LONG(&val, v);