Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/ftp/ftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ bool ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, const size_
#else
while (e > ptr && (s = memchr(ptr, '\r', (e - ptr)))) {
php_stream_write(outstream, ptr, (s - ptr));
if (*(s + 1) == '\n') {
if (s + 1 < e && *(s + 1) == '\n') {
s++;
php_stream_putc(outstream, '\n');
}
Expand Down
25 changes: 25 additions & 0 deletions ext/ftp/tests/ftp_get_ascii_crlf_boundary.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--TEST--
ftp_get() ASCII mode: CRLF straddling the FTP_BUFSIZE read boundary
--EXTENSIONS--
ftp
pcntl
--FILE--
<?php
require 'server.inc';

$ftp = ftp_connect('127.0.0.1', $port);
ftp_login($ftp, 'user', 'pass');
$ftp or die("Couldn't connect to the server");

$local = __DIR__ . "/crlf_boundary_out.txt";

var_dump(ftp_get($ftp, $local, 'crlf_boundary', FTP_ASCII));
var_dump(file_get_contents($local) === str_repeat("A", 4095) . "\n" . str_repeat("B", 10));
?>
--CLEAN--
<?php
@unlink(__DIR__ . "/crlf_boundary_out.txt");
?>
--EXPECT--
bool(true)
bool(true)
7 changes: 7 additions & 0 deletions ext/ftp/tests/server.inc
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,13 @@ if ($pid) {
// Just a side channel for getting the received file size.
fputs($s, "425 Can't open data connection (".$GLOBALS['rest_pos'].").\r\n");
break;
case "crlf_boundary":
// A CRLF whose CR lands on the final byte of the first
// FTP_BUFSIZE (4096) read, so the LF arrives in the next read.
fputs($s, "150 File status okay; about to open data connection.\r\n");
fputs($fs, str_repeat("A", 4095) . "\r\n" . str_repeat("B", 10));
fputs($s, "226 Closing data Connection.\r\n");
break;

default:
fputs($s, "550 {$matches[1]}: No such file or directory \r\n");
Expand Down
6 changes: 2 additions & 4 deletions ext/standard/io_poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,9 @@ typedef struct php_stream_poll_handle_data {
} php_stream_poll_handle_data;

/* Accessor macros */
#define PHP_POLL_CONTEXT_OBJ_FROM_ZOBJ(_obj) \
((php_io_poll_context_object *) ((char *) (_obj) - offsetof(php_io_poll_context_object, std)))
#define PHP_POLL_CONTEXT_OBJ_FROM_ZOBJ(_obj) ZEND_CONTAINER_OF(_obj, php_io_poll_context_object, std)

#define PHP_POLL_WATCHER_OBJ_FROM_ZOBJ(_obj) \
((php_io_poll_watcher_object *) ((char *) (_obj) - offsetof(php_io_poll_watcher_object, std)))
#define PHP_POLL_WATCHER_OBJ_FROM_ZOBJ(_obj) ZEND_CONTAINER_OF(_obj, php_io_poll_watcher_object, std)

#define PHP_POLL_WATCHER_OBJ_FROM_ZV(_zv) PHP_POLL_WATCHER_OBJ_FROM_ZOBJ(Z_OBJ_P(_zv))
#define PHP_POLL_CONTEXT_OBJ_FROM_ZV(_zv) PHP_POLL_CONTEXT_OBJ_FROM_ZOBJ(Z_OBJ_P(_zv))
Expand Down
3 changes: 1 addition & 2 deletions main/php_poll.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ struct php_poll_handle_object {
zend_object std;
};

#define PHP_POLL_HANDLE_OBJ_FROM_ZOBJ(obj) \
((php_poll_handle_object *) ((char *) (obj) - offsetof(php_poll_handle_object, std)))
#define PHP_POLL_HANDLE_OBJ_FROM_ZOBJ(obj) ZEND_CONTAINER_OF(obj, php_poll_handle_object, std)

#define PHP_POLL_HANDLE_OBJ_FROM_ZV(zv) PHP_POLL_HANDLE_OBJ_FROM_ZOBJ(Z_OBJ_P(zv))

Expand Down
2 changes: 1 addition & 1 deletion win32/build/config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ ADD_SOURCES("win32", "dllmain.c readdir.c \

ADD_FLAG("CFLAGS_BD_WIN32", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1");

PHP_INSTALL_HEADERS("", "Zend/ TSRM/ main/ main/poll/ main/streams/ win32/");
PHP_INSTALL_HEADERS("", "Zend/ TSRM/ main/ main/streams/ win32/");
PHP_INSTALL_HEADERS("Zend/Optimizer", "zend_call_graph.h zend_cfg.h zend_dfg.h zend_dump.h zend_func_info.h zend_inference.h zend_optimizer.h zend_ssa.h zend_worklist.h");

STDOUT.WriteBlankLines(1);
Expand Down