version 1.1.1.3, 2013/07/22 01:31:50
|
version 1.1.1.4, 2013/10/14 08:02:19
|
Line 39
|
Line 39
|
#ifdef PHP_WIN32 |
#ifdef PHP_WIN32 |
#include <winsock2.h> |
#include <winsock2.h> |
#elif defined(NETWARE) |
#elif defined(NETWARE) |
#ifdef USE_WINSOCK /* Modified to use Winsock (NOVSOCK2.H), atleast for now */ | #ifdef USE_WINSOCK /* Modified to use Winsock (NOVSOCK2.H), at least for now */ |
#include <novsock2.h> |
#include <novsock2.h> |
#else |
#else |
#include <sys/socket.h> |
#include <sys/socket.h> |
Line 182 ftp_close(ftpbuf_t *ftp)
|
Line 182 ftp_close(ftpbuf_t *ftp)
|
#if HAVE_OPENSSL_EXT |
#if HAVE_OPENSSL_EXT |
if (ftp->ssl_active) { |
if (ftp->ssl_active) { |
SSL_shutdown(ftp->ssl_handle); |
SSL_shutdown(ftp->ssl_handle); |
|
SSL_free(ftp->ssl_handle); |
} |
} |
#endif |
#endif |
closesocket(ftp->fd); |
closesocket(ftp->fd); |
Line 297 ftp_login(ftpbuf_t *ftp, const char *user, const char
|
Line 298 ftp_login(ftpbuf_t *ftp, const char *user, const char
|
if (SSL_connect(ftp->ssl_handle) <= 0) { |
if (SSL_connect(ftp->ssl_handle) <= 0) { |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "SSL/TLS handshake failed"); |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "SSL/TLS handshake failed"); |
SSL_shutdown(ftp->ssl_handle); |
SSL_shutdown(ftp->ssl_handle); |
|
SSL_free(ftp->ssl_handle); |
return 0; |
return 0; |
} |
} |
|
|
Line 610 ftp_chmod(ftpbuf_t *ftp, const int mode, const char *f
|
Line 612 ftp_chmod(ftpbuf_t *ftp, const int mode, const char *f
|
/* {{{ ftp_alloc |
/* {{{ ftp_alloc |
*/ |
*/ |
int |
int |
ftp_alloc(ftpbuf_t *ftp, const int size, char **response) | ftp_alloc(ftpbuf_t *ftp, const long size, char **response) |
{ |
{ |
char buffer[64]; |
char buffer[64]; |
|
|
Line 618 ftp_alloc(ftpbuf_t *ftp, const int size, char **respon
|
Line 620 ftp_alloc(ftpbuf_t *ftp, const int size, char **respon
|
return 0; |
return 0; |
} |
} |
|
|
snprintf(buffer, sizeof(buffer) - 1, "%d", size); | snprintf(buffer, sizeof(buffer) - 1, "%ld", size); |
| |
if (!ftp_putcmd(ftp, "ALLO", buffer)) { |
if (!ftp_putcmd(ftp, "ALLO", buffer)) { |
return 0; |
return 0; |
} |
} |
Line 785 ftp_pasv(ftpbuf_t *ftp, int pasv)
|
Line 787 ftp_pasv(ftpbuf_t *ftp, int pasv)
|
/* {{{ ftp_get |
/* {{{ ftp_get |
*/ |
*/ |
int |
int |
ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, int resumepos TSRMLS_DC) | ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, long resumepos TSRMLS_DC) |
{ |
{ |
databuf_t *data = NULL; |
databuf_t *data = NULL; |
int lastch; |
int lastch; |
Line 806 ftp_get(ftpbuf_t *ftp, php_stream *outstream, const ch
|
Line 808 ftp_get(ftpbuf_t *ftp, php_stream *outstream, const ch
|
ftp->data = data; |
ftp->data = data; |
|
|
if (resumepos > 0) { |
if (resumepos > 0) { |
if (resumepos > 2147483647) { | snprintf(arg, sizeof(arg), "%ld", resumepos); |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "PHP cannot handle files greater than 2147483647 bytes."); | |
goto bail; | |
} | |
snprintf(arg, sizeof(arg), "%u", resumepos); | |
if (!ftp_putcmd(ftp, "REST", arg)) { |
if (!ftp_putcmd(ftp, "REST", arg)) { |
goto bail; |
goto bail; |
} |
} |
Line 883 bail:
|
Line 881 bail:
|
/* {{{ ftp_put |
/* {{{ ftp_put |
*/ |
*/ |
int |
int |
ftp_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, int startpos TSRMLS_DC) | ftp_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, long startpos TSRMLS_DC) |
{ |
{ |
databuf_t *data = NULL; |
databuf_t *data = NULL; |
int size; | long size; |
char *ptr; |
char *ptr; |
int ch; |
int ch; |
char arg[11]; |
char arg[11]; |
Line 903 ftp_put(ftpbuf_t *ftp, const char *path, php_stream *i
|
Line 901 ftp_put(ftpbuf_t *ftp, const char *path, php_stream *i
|
ftp->data = data; |
ftp->data = data; |
|
|
if (startpos > 0) { |
if (startpos > 0) { |
if (startpos > 2147483647) { | snprintf(arg, sizeof(arg), "%ld", startpos); |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "PHP cannot handle files with a size greater than 2147483647 bytes."); | |
goto bail; | |
} | |
snprintf(arg, sizeof(arg), "%u", startpos); | |
if (!ftp_putcmd(ftp, "REST", arg)) { |
if (!ftp_putcmd(ftp, "REST", arg)) { |
goto bail; |
goto bail; |
} |
} |
Line 964 bail:
|
Line 958 bail:
|
|
|
/* {{{ ftp_size |
/* {{{ ftp_size |
*/ |
*/ |
int | long |
ftp_size(ftpbuf_t *ftp, const char *path) |
ftp_size(ftpbuf_t *ftp, const char *path) |
{ |
{ |
if (ftp == NULL) { |
if (ftp == NULL) { |
Line 979 ftp_size(ftpbuf_t *ftp, const char *path)
|
Line 973 ftp_size(ftpbuf_t *ftp, const char *path)
|
if (!ftp_getresp(ftp) || ftp->resp != 213) { |
if (!ftp_getresp(ftp) || ftp->resp != 213) { |
return -1; |
return -1; |
} |
} |
return atoi(ftp->inbuf); | return atol(ftp->inbuf); |
} |
} |
/* }}} */ |
/* }}} */ |
|
|
Line 1141 ftp_putcmd(ftpbuf_t *ftp, const char *cmd, const char
|
Line 1135 ftp_putcmd(ftpbuf_t *ftp, const char *cmd, const char
|
int |
int |
ftp_readline(ftpbuf_t *ftp) |
ftp_readline(ftpbuf_t *ftp) |
{ |
{ |
int size, rcvd; | long size, rcvd; |
char *data, *eol; |
char *data, *eol; |
|
|
/* shift the extra to the front */ |
/* shift the extra to the front */ |
Line 1234 ftp_getresp(ftpbuf_t *ftp)
|
Line 1228 ftp_getresp(ftpbuf_t *ftp)
|
int |
int |
my_send(ftpbuf_t *ftp, php_socket_t s, void *buf, size_t len) |
my_send(ftpbuf_t *ftp, php_socket_t s, void *buf, size_t len) |
{ |
{ |
int n, size, sent; | long size, sent; |
| int n; |
|
|
size = len; |
size = len; |
while (size) { |
while (size) { |
Line 1548 data_accepted:
|
Line 1543 data_accepted:
|
if (SSL_connect(data->ssl_handle) <= 0) { |
if (SSL_connect(data->ssl_handle) <= 0) { |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "data_accept: SSL/TLS handshake failed"); |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "data_accept: SSL/TLS handshake failed"); |
SSL_shutdown(data->ssl_handle); |
SSL_shutdown(data->ssl_handle); |
|
SSL_free(data->ssl_handle); |
return 0; |
return 0; |
} |
} |
|
|
Line 1565 data_accepted:
|
Line 1561 data_accepted:
|
databuf_t* |
databuf_t* |
data_close(ftpbuf_t *ftp, databuf_t *data) |
data_close(ftpbuf_t *ftp, databuf_t *data) |
{ |
{ |
|
#if HAVE_OPENSSL_EXT |
|
SSL_CTX *ctx; |
|
#endif |
if (data == NULL) { |
if (data == NULL) { |
return NULL; |
return NULL; |
} |
} |
if (data->listener != -1) { |
if (data->listener != -1) { |
#if HAVE_OPENSSL_EXT |
#if HAVE_OPENSSL_EXT |
if (data->ssl_active) { |
if (data->ssl_active) { |
|
|
|
ctx = SSL_get_SSL_CTX(data->ssl_handle); |
|
SSL_CTX_free(ctx); |
|
|
SSL_shutdown(data->ssl_handle); |
SSL_shutdown(data->ssl_handle); |
|
SSL_free(data->ssl_handle); |
data->ssl_active = 0; |
data->ssl_active = 0; |
} |
} |
#endif |
#endif |
Line 1580 data_close(ftpbuf_t *ftp, databuf_t *data)
|
Line 1584 data_close(ftpbuf_t *ftp, databuf_t *data)
|
if (data->fd != -1) { |
if (data->fd != -1) { |
#if HAVE_OPENSSL_EXT |
#if HAVE_OPENSSL_EXT |
if (data->ssl_active) { |
if (data->ssl_active) { |
|
ctx = SSL_get_SSL_CTX(data->ssl_handle); |
|
SSL_CTX_free(ctx); |
|
|
SSL_shutdown(data->ssl_handle); |
SSL_shutdown(data->ssl_handle); |
|
SSL_free(data->ssl_handle); |
data->ssl_active = 0; |
data->ssl_active = 0; |
} |
} |
#endif |
#endif |
Line 1704 bail:
|
Line 1712 bail:
|
/* {{{ ftp_nb_get |
/* {{{ ftp_nb_get |
*/ |
*/ |
int |
int |
ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, int resumepos TSRMLS_DC) | ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, long resumepos TSRMLS_DC) |
{ |
{ |
databuf_t *data = NULL; |
databuf_t *data = NULL; |
char arg[11]; |
char arg[11]; |
Line 1722 ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const
|
Line 1730 ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const
|
} |
} |
|
|
if (resumepos>0) { |
if (resumepos>0) { |
/* We are working on an architecture that supports 64-bit integers | snprintf(arg, sizeof(arg), "%ld", resumepos); |
* since php is 32 bit by design, we bail out with warning | |
*/ | |
if (resumepos > 2147483647) { | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "PHP cannot handle files greater than 2147483648 bytes."); | |
goto bail; | |
} | |
snprintf(arg, sizeof(arg), "%u", resumepos); | |
if (!ftp_putcmd(ftp, "REST", arg)) { |
if (!ftp_putcmd(ftp, "REST", arg)) { |
goto bail; |
goto bail; |
} |
} |
Line 1828 bail:
|
Line 1829 bail:
|
/* {{{ ftp_nb_put |
/* {{{ ftp_nb_put |
*/ |
*/ |
int |
int |
ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, int startpos TSRMLS_DC) | ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, long startpos TSRMLS_DC) |
{ |
{ |
databuf_t *data = NULL; |
databuf_t *data = NULL; |
char arg[11]; |
char arg[11]; |
Line 1843 ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream
|
Line 1844 ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream
|
goto bail; |
goto bail; |
} |
} |
if (startpos > 0) { |
if (startpos > 0) { |
if (startpos > 2147483647) { | snprintf(arg, sizeof(arg), "%ld", startpos); |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "PHP cannot handle files with a size greater than 2147483647 bytes."); | |
goto bail; | |
} | |
snprintf(arg, sizeof(arg), "%u", startpos); | |
if (!ftp_putcmd(ftp, "REST", arg)) { |
if (!ftp_putcmd(ftp, "REST", arg)) { |
goto bail; |
goto bail; |
} |
} |
Line 1884 bail:
|
Line 1881 bail:
|
int |
int |
ftp_nb_continue_write(ftpbuf_t *ftp TSRMLS_DC) |
ftp_nb_continue_write(ftpbuf_t *ftp TSRMLS_DC) |
{ |
{ |
int size; | long size; |
char *ptr; |
char *ptr; |
int ch; |
int ch; |
|
|