Skip to content

Commit abc6fe8

Browse files
nielsdosiluuu1994
authored andcommitted
Propagate success status of ftp_close() to userland
The docs say that this function returns true on success, and false on error. This function always returns true in the current implementation because the success return value from ftp_close() is never propagated to userland. This affects one test: since the test server exits after an invalid login, the ftp close correctly fails (because the server has gone away).
1 parent ffc2a53 commit abc6fe8

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ PHP NEWS
66
. Added optional support for max_execution_time in ZTS/Linux builds
77
(Kévin Dunglas)
88

9+
- FTP:
10+
. Propagate success status of ftp_close(). (nielsdos)
11+
912
- Opcache:
1013
. Fixed build for macOS to cater with pkg-config settings. (David Carlier)
1114

ext/ftp/php_ftp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,19 +1224,20 @@ PHP_FUNCTION(ftp_close)
12241224
{
12251225
zval *z_ftp;
12261226
php_ftp_object *obj;
1227+
bool success = true;
12271228

12281229
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &z_ftp, php_ftp_ce) == FAILURE) {
12291230
RETURN_THROWS();
12301231
}
12311232

12321233
obj = ftp_object_from_zend_object(Z_OBJ_P(z_ftp));
12331234
if (obj->ftp) {
1234-
ftp_quit(obj->ftp);
1235+
success = ftp_quit(obj->ftp);
12351236
ftp_close(obj->ftp);
12361237
obj->ftp = NULL;
12371238
}
12381239

1239-
RETURN_TRUE;
1240+
RETURN_BOOL(success);
12401241
}
12411242
/* }}} */
12421243

ext/ftp/tests/004.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ bool(true)
2828

2929
Warning: ftp_login(): Not logged in. in %s on line %d
3030
bool(false)
31-
bool(true)
31+
bool(false)

ext/ftp/tests/server.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ if ($pid) {
183183
fputs($s, "200 OK\r\n");
184184

185185
} elseif ($buf === "QUIT\r\n") {
186+
fputs($s, "221 Bye\r\n");
186187
break;
187188

188189
} elseif (preg_match("~^PORT (\d+),(\d+),(\d+),(\d+),(\d+),(\d+)\r\n$~", $buf, $m)) {

0 commit comments

Comments
 (0)