xref: /php-src/ext/zend_test/tests/gh10370_1.phpt (revision 10f23785)
1--TEST--
2GH-10370: File corruption in _php_stream_copy_to_stream_ex when using copy_file_range - partial copy
3--EXTENSIONS--
4zend_test
5phar
6--SKIPIF--
7<?php
8if (PHP_OS != 'Linux') {
9    die('skip For Linux only');
10}
11?>
12--INI--
13zend_test.limit_copy_file_range=3584
14--FILE--
15<?php
16/* Note: the value 3584 is chosen so that the mmap in _php_stream_copy_to_stream_ex() will mmap
17 *       at an offset of a multiple of 4096, which is the standard page size in most Linux systems. */
18$archive = new PharData(__DIR__ . DIRECTORY_SEPARATOR . 'gh10370.tar');
19var_dump($archive->extractTo(__DIR__ . DIRECTORY_SEPARATOR . 'gh10370_001', ['testfile']));
20var_dump(sha1_file(__DIR__ . DIRECTORY_SEPARATOR . 'gh10370_001' . DIRECTORY_SEPARATOR . 'testfile'));
21?>
22--EXPECT--
23bool(true)
24string(40) "a723ae4ec7eababff73ca961a771b794be6388d2"
25--CLEAN--
26<?php
27@unlink(__DIR__ . DIRECTORY_SEPARATOR . 'gh10370_001' . DIRECTORY_SEPARATOR . 'testfile');
28@rmdir(__DIR__ . DIRECTORY_SEPARATOR . 'gh10370_001');
29?>
30