xref: /PHP-8.3/ext/standard/tests/http/gh15034.phpt (revision cfcc2a3f)
1--TEST--
2GH-15034 (Integer overflow on stream_notification_callback byte_max parameter with files bigger than 2GB)
3--SKIPIF--
4<?php
5require 'server.inc';
6http_server_skipif();
7if (PHP_INT_SIZE != 8) die("skip 64-bit only");
8?>
9--INI--
10allow_url_fopen=1
11--FILE--
12<?php
13require 'server.inc';
14
15$responses = [
16    "data://text/plain,HTTP/1.1 200 OK\r\n"
17    . "Content-Type: text/plain\r\n"
18    . "Content-Length: 3000000000\r\n\r\n"
19    . "foo\n",
20];
21['pid' => $pid, 'uri' => $uri] = http_server($responses);
22
23$params = ['notification' => function(
24    int $notification_code,
25    int $severity,
26    ?string $message,
27    int $message_code,
28    int $bytes_transferred,
29    int $bytes_max
30) {
31    global $max;
32    $max = $bytes_max;
33}];
34$contextResource = stream_context_create([], $params);
35
36$resource = fopen($uri, 'r', false, $contextResource);
37fclose($resource);
38
39http_server_kill($pid);
40
41var_dump($max);
42?>
43--EXPECT--
44int(3000000000)
45