diff options
Diffstat (limited to 'ext/ftp/ftp.c')
-rw-r--r-- | ext/ftp/ftp.c | 54 |
1 files changed, 18 insertions, 36 deletions
diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c index dd41f02704..0d6704f9d2 100644 --- a/ext/ftp/ftp.c +++ b/ext/ftp/ftp.c @@ -612,7 +612,7 @@ ftp_chmod(ftpbuf_t *ftp, const int mode, const char *filename, const int filenam /* {{{ ftp_alloc */ int -ftp_alloc(ftpbuf_t *ftp, const int size, char **response) +ftp_alloc(ftpbuf_t *ftp, const long size, char **response) { char buffer[64]; @@ -620,8 +620,8 @@ ftp_alloc(ftpbuf_t *ftp, const int size, char **response) return 0; } - snprintf(buffer, sizeof(buffer) - 1, "%d", size); - + snprintf(buffer, sizeof(buffer) - 1, "%ld", size); + if (!ftp_putcmd(ftp, "ALLO", buffer)) { return 0; } @@ -787,7 +787,7 @@ ftp_pasv(ftpbuf_t *ftp, int pasv) /* {{{ ftp_get */ 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; int lastch; @@ -808,11 +808,7 @@ ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, ftp->data = data; if (resumepos > 0) { - if (resumepos > 2147483647) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "PHP cannot handle files greater than 2147483647 bytes."); - goto bail; - } - snprintf(arg, sizeof(arg), "%u", resumepos); + snprintf(arg, sizeof(arg), "%ld", resumepos); if (!ftp_putcmd(ftp, "REST", arg)) { goto bail; } @@ -885,10 +881,10 @@ bail: /* {{{ ftp_put */ 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; - int size; + long size; char *ptr; int ch; char arg[11]; @@ -905,11 +901,7 @@ ftp_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, i ftp->data = data; if (startpos > 0) { - if (startpos > 2147483647) { - 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); + snprintf(arg, sizeof(arg), "%ld", startpos); if (!ftp_putcmd(ftp, "REST", arg)) { goto bail; } @@ -966,7 +958,7 @@ bail: /* {{{ ftp_size */ -int +long ftp_size(ftpbuf_t *ftp, const char *path) { if (ftp == NULL) { @@ -981,7 +973,7 @@ ftp_size(ftpbuf_t *ftp, const char *path) if (!ftp_getresp(ftp) || ftp->resp != 213) { return -1; } - return atoi(ftp->inbuf); + return atol(ftp->inbuf); } /* }}} */ @@ -1143,7 +1135,7 @@ ftp_putcmd(ftpbuf_t *ftp, const char *cmd, const char *args) int ftp_readline(ftpbuf_t *ftp) { - int size, rcvd; + long size, rcvd; char *data, *eol; /* shift the extra to the front */ @@ -1236,7 +1228,8 @@ ftp_getresp(ftpbuf_t *ftp) int 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; while (size) { @@ -1719,7 +1712,7 @@ bail: /* {{{ ftp_nb_get */ 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; char arg[11]; @@ -1737,14 +1730,7 @@ ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t typ } if (resumepos>0) { - /* We are working on an architecture that supports 64-bit integers - * 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); + snprintf(arg, sizeof(arg), "%ld", resumepos); if (!ftp_putcmd(ftp, "REST", arg)) { goto bail; } @@ -1843,7 +1829,7 @@ bail: /* {{{ ftp_nb_put */ 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; char arg[11]; @@ -1858,11 +1844,7 @@ ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type goto bail; } if (startpos > 0) { - if (startpos > 2147483647) { - 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); + snprintf(arg, sizeof(arg), "%ld", startpos); if (!ftp_putcmd(ftp, "REST", arg)) { goto bail; } @@ -1899,7 +1881,7 @@ bail: int ftp_nb_continue_write(ftpbuf_t *ftp TSRMLS_DC) { - int size; + long size; char *ptr; int ch; |