xref: /PHP-8.2/ext/zend_test/tests/gh10370_2.phpt (revision 10f23785)
1--TEST--
2GH-10370: File corruption in _php_stream_copy_to_stream_ex when using copy_file_range - unlimited copy
3--EXTENSIONS--
4zend_test
5--SKIPIF--
6<?php
7if (PHP_OS != 'Linux') {
8    die('skip For Linux only');
9}
10?>
11--INI--
12zend_test.limit_copy_file_range=4096
13--FILE--
14<?php
15/* Note: the value 4096 is chosen so that the mmap in _php_stream_copy_to_stream_ex() will mmap
16 *       at an offset of a multiple of 4096, which is the standard page size in most Linux systems. */
17$input_file = fopen(__DIR__ . DIRECTORY_SEPARATOR . 'gh10370.tar', 'r');
18file_put_contents(__DIR__ . DIRECTORY_SEPARATOR . 'gh10370_002_out.tar', $input_file);
19fclose($input_file);
20
21var_dump(sha1_file(__DIR__ . DIRECTORY_SEPARATOR . 'gh10370.tar'));
22var_dump(sha1_file(__DIR__ . DIRECTORY_SEPARATOR . 'gh10370_002_out.tar'));
23?>
24--EXPECT--
25string(40) "edcad8cd6c276f5e318c826ad77a5604d6a6e93d"
26string(40) "edcad8cd6c276f5e318c826ad77a5604d6a6e93d"
27--CLEAN--
28<?php
29@unlink(__DIR__ . DIRECTORY_SEPARATOR . 'gh10370_002_out.tar');
30?>
31