Skip to content

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

Closed

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

Activity

  1. self-assigned this
    on Aug 28, 2024
  2. added a commit that references this issue on Sep 10, 2024
    c4478d4
  3. added a commit that references this issue on Sep 11, 2024
    791a6ef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions