Skip to content

main/io & main/poll: 32-bit integer overflow in timeout_ms calculation and kqueue realloc size #25860

Done

Description

@OmenP007

Description

  1. main/io/php_io_copy_windows.c:51, php_io_copy_linux.c:55, php_io.c:106: int timeout_ms = fd->timeout.tv_sec * 1000 + fd->timeout.tv_usec / 1000; overflows 32-bit int when tv_sec > INT_MAX / 1000, turning a large finite timeout into a negative value (WSAPoll/poll infinite wait).
  2. main/poll/poll_backend_kqueue.c:304 (and epoll/wsapoll/eventport): max_events * sizeof(struct kevent) in php_poll_realloc() lacks a 32-bit size_t multiplication overflow check.
    Suggested fix: Compute timeout_ms in int64_t clamped to [0, INT_MAX] (keeping -1 only for tv_sec == -1), and check (size_t)max_events <= SIZE_MAX / sizeof(...) before php_poll_realloc().

PHP Version

8.6.0

Operating System

Any

Activity

  1. added a commit that references this issue on Nov 29, 2026
    9e78ae2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions