-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix GH-10521: ftp_get/ftp_nb_get resumepos offset is maximum 10GB
The char arrays were too small for a long on 64-bit systems, which resulted in cutting off the string at the end with a NUL byte. Use a size of MAX_LENGTH_OF_LONG to fix this issue instead of a fixed size of 11 chars. Closes GH-10525.
- Loading branch information
Showing
4 changed files
with
49 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--TEST-- | ||
GH-10521 (ftp_get/ftp_nb_get resumepos offset is maximum 10GB) | ||
--EXTENSIONS-- | ||
ftp | ||
pcntl | ||
--SKIPIF-- | ||
<?php | ||
if (PHP_INT_SIZE != 8) die("skip: 64-bit only"); | ||
?> | ||
--FILE-- | ||
<?php | ||
require 'server.inc'; | ||
|
||
$ftp = ftp_connect('127.0.0.1', $port); | ||
if (!$ftp) die("Couldn't connect to the server"); | ||
|
||
var_dump(ftp_login($ftp, 'anonymous', 'IEUser@')); | ||
|
||
$local_file = __DIR__ . DIRECTORY_SEPARATOR . "gh10521.txt"; | ||
|
||
foreach ([12345678910, 9223372036854775807] as $size) { | ||
$handle = fopen($local_file, 'w'); | ||
// Doesn't actually succeed in transferring a file. The file transfer gets aborted by our fake server. | ||
// We just want to see if the offset was correctly received. | ||
ftp_fget($ftp, $handle, 'gh10521', FTP_ASCII, $size); | ||
fclose($handle); | ||
} | ||
|
||
?> | ||
--CLEAN-- | ||
<?php | ||
@unlink(__DIR__ . DIRECTORY_SEPARATOR . "gh10521.txt"); | ||
?> | ||
--EXPECTF-- | ||
bool(true) | ||
|
||
%s: ftp_fget(): Can't open data connection (12345678910). in %s on line %d | ||
|
||
%s: ftp_fget(): Can't open data connection (9223372036854775807). in %s on line %d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters