Skip to content

Signed integer overflow in ext/standard/pack.c #15613

Closed
@YuanchengJiang

Description

@YuanchengJiang

Description

The following code:

<?php
unpack('h2147483647', str_repeat('X', 2**31 + 10));
?>

Resulted in this output:

/php-src/ext/standard/pack.c:981:36: runtime error: signed integer overflow: 1073741824 * 2 cannot be represented in type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /php-src/ext/standard/pack.c:981:36 in

To reproduce:

php -d "memory_limit=-1" test.php

PHP Version

PHP 8.4.0-dev

Operating System

ubuntu 22.04

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions