Skip to content

Signed Integer Overflow in pack() #18976

Closed
@bendrissou

Description

@bendrissou

Description

The following code:

<?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

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions