[php-src] Issue #13203: file_put_contents fail on strings over 4GB on Windows 10
| From: | divinity76 | Date: | Sat, 20 Jan 2024 17:59:53 +0000 |
| Subject: | [php-src] Issue #13203: file_put_contents fail on strings over 4GB on Windows 10 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-246300@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/13203
Author: divinity76
### Description
The following cmd.exe invocation:
```php
php -r "ini_set('memory_limit', '6G'); $size = 5 * 1024 * 1024 * 1024; $str
= str_repeat(\"\x00\", $size); file_put_contents('test.bin', $str);"
dir
```
Resulted in this output:
```
C:\reproduce>php -r "ini_set('memory_limit', '6G'); $size = 5 * 1024 *
1024 * 1024; $str = str_repeat(\"\x00\", $size); file_put_contents('test.bin',
$str);"
PHP Notice: file_put_contents(): Write of 4294967295 bytes failed with errno=0 No error in Command
line code on line 1
Notice: file_put_contents(): Write of 4294967295 bytes failed with errno=0 No error in Command line
code on line 1
C:\reproduce>dir
Volume in drive C has no label.
Volume Serial Number is 445C-1EDF
Directory of C:\reproduce
20/01/2024 18:41 <DIR> .
20/01/2024 18:41 <DIR> ..
20/01/2024 18:41 4,294,967,295 test.bin
1 File(s) 4,294,967,295 bytes
2 Dir(s) 2,580,218,351,616 bytes free
```
But I expected this output instead:
```
C:\reproduce>php -r "ini_set('memory_limit', '6G'); $size = 5 * 1024 *
1024 * 1024; $str = str_repeat(\"\x00\", $size); file_put_contents('test.bin',
$str);"
C:\reproduce>dir
Volume in drive C has no label.
Volume Serial Number is 445C-1EDF
Directory of C:\reproduce
20/01/2024 18:41 <DIR> .
20/01/2024 18:41 <DIR> ..
20/01/2024 18:41 5,368,709,120 test.bin
1 File(s) 5,368,709,120 bytes
2 Dir(s) 2,580,218,351,616 bytes free
```
### PHP Version
PHP 8.3.0
### Operating System
Windows 10 x64 22H2