From 0fff8fe6a7830cdc8349df6eddad7bb2d82710e5 Mon Sep 17 00:00:00 2001 From: Uliya Shevchenko Date: Sun, 11 Oct 2026 12:48:21 +0300 Subject: [PATCH] Fix: SIGN_EXTENSION 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 Signed-off-by: Georgij Tsarin --- ext/standard/pack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/standard/pack.c b/ext/standard/pack.c index 969f5a2db742..3c6bb7c35e2f 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);