[php-src] Issue #18976: Signed Integer Overflow in pack()

From: Date: Sun, 29 Jun 2025 11:37:26 +0000
Subject: [php-src] Issue #18976: Signed Integer Overflow in pack()
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-250341@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/18976 Author: bendrissou ### Description The following code: ```php <?php pack('h2147483647', 1); ?> ``` Resulted in this output: ``` /home/program/ext/standard/pack.c:389:5: runtime error: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/program/ext/standard/pack.c:389:5 in ``` But I expected this output instead: ``` Warning: pack(): Type h: not enough characters in string in /home/bug-1.php on line 3 ``` ### PHP Version ```plain PHP 8.5.0-dev (cli) (built: Jun 4 2025 20:21:49) (NTS) Copyright (c) The PHP Group Zend Engine v4.5.0-dev, Copyright (c) Zend Technologies ``` ### Operating System Ubuntu 20.04

« previous php.bugs (#250341) next »