Skip to content

php_network.h integer overflow #15937

Closed
Closed

Description

@chongwick

Description

The following code:

<?php
array( 'timeout' => PHP_INT_MAX, 'max_redirects' => PHP_INT_MAX, 'user_agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3', ), ));
$fp = fopen('http://example.com', 'r', false, $stream);

Resulted in this output:

/home/dan/php-8.3.9/main/php_network.h:166:29: runtime error: signed integer overflow: -9223372036854775808 * 1000 cannot be represented in type 'long int'

PHP Version

8.3.9

Operating System

No response

Activity

  1. cmb69 commented on Sep 17, 2024

    @cmb69
    Member

    php-src/main/php_network.h

    Lines 163 to 168 in 67ba890

    static inline int php_tvtoto(struct timeval *timeouttv)
    {
    if (timeouttv) {
    return (timeouttv->tv_sec * 1000) + (timeouttv->tv_usec / 1000);
    }
    return -1;

    looks indeed fishy.

  2. self-assigned this
    on Sep 17, 2024
  3. added a commit that references this issue on Sep 17, 2024
    7275292
  4. added a commit that references this issue on Sep 30, 2024
    332b067
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