php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76422 ftruncate fails on files > 2GB
Submitted: 2018-06-07 05:23 UTC Modified: 2018-06-08 07:47 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: yani at iliev dot me Assigned: ab (profile)
Status: Closed Package: Filesystem function related
PHP Version: 7.2.6 OS: Windows 10 Pro x64
Private report: No CVE-ID: None
 [2018-06-07 05:23 UTC] yani at iliev dot me
Description:
------------
ftruncate returns false when the file being truncated is > 2GB and the offset is also > 2GB.
This only occurs on Windows and not on Linux/Mac

Test script:
---------------
<?php
$file_handle = fopen('test','cb');

if (false === $file_handle) {
    die('Cannot open test file :/');
}

$truncate_offset = 2 * 1024 * 1024 * 1024 + 1; // 2GB + 1
$ftruncate_result = ftruncate($file_handle, $truncate_offset);

if (false === $ftruncate_result) {
    die('Truncate has failed :/');
}

fclose($file_handle);


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-06-07 16:49 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2018-06-07 16:49 UTC] cmb@php.net
Do you actually use a 64bit build?
 [2018-06-07 19:49 UTC] yani at iliev dot me
-Status: Feedback +Status: Assigned
 [2018-06-07 19:49 UTC] yani at iliev dot me
Yes, 64Bit build of PHP.
PHP_INT_SIZE is 8
 [2018-06-07 21:13 UTC] cmb@php.net
-Status: Assigned +Status: Open -Assigned To: cmb +Assigned To:
 [2018-06-08 07:47 UTC] ab@php.net
-Assigned To: +Assigned To: ab
 [2018-06-09 09:32 UTC] ab@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=9cd2d77514aa71359eac0ea080901e7c021681c9
Log: Fixed bug #76422 ftruncate fails on files &gt; 2GB
 [2018-06-09 09:32 UTC] ab@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Wed Dec 12 08:01:25 2018 UTC