diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c index dfe905a8c220..0214b8119e06 100644 --- a/ext/standard/ftp_fopen_wrapper.c +++ b/ext/standard/ftp_fopen_wrapper.c @@ -269,6 +269,8 @@ static php_stream *php_ftp_fopen_connect(php_stream_wrapper *wrapper, const char /* if the user has configured who they are, send that as the password */ if (FG(from_address)) { + PHP_FTP_CNTRL_CHK(ZSTR_VAL(FG(from_address)), ZSTR_LEN(FG(from_address)), "Invalid password %s") + php_stream_printf(stream, "PASS %s\r\n", ZSTR_VAL(FG(from_address))); } else { php_stream_write_string(stream, "PASS anonymous\r\n"); diff --git a/ext/standard/tests/streams/ftp_from_address_cntrl.phpt b/ext/standard/tests/streams/ftp_from_address_cntrl.phpt new file mode 100644 index 000000000000..dd64e0c1e34d --- /dev/null +++ b/ext/standard/tests/streams/ftp_from_address_cntrl.phpt @@ -0,0 +1,54 @@ +--TEST-- +ftp:// wrapper must reject control characters in the from address sent as the anonymous password +--SKIPIF-- + +--FILE-- + +--EXPECT-- +bool(false) +bool(false) +bool(false)