[PHP-CVS] cvs: php-src /ext/standard ftp_fopen_wrapper.c
felipe Fri Jul 11 18:34:43 2008 UTC Modified files: /php-src/ext/standard ftp_fopen_wrapper.c Log: - MFB: Fixed bug #45449 (filesize() regression using ftp wrapper) (patch by crrodriguez at suse dot de) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/ftp_fopen_wrapper.c?r1=1.102r2=1.103diff_format=u Index: php-src/ext/standard/ftp_fopen_wrapper.c diff -u php-src/ext/standard/ftp_fopen_wrapper.c:1.102 php-src/ext/standard/ftp_fopen_wrapper.c:1.103 --- php-src/ext/standard/ftp_fopen_wrapper.c:1.102 Tue Jan 8 19:09:12 2008 +++ php-src/ext/standard/ftp_fopen_wrapper.cFri Jul 11 18:34:43 2008 @@ -18,7 +18,7 @@ | Sara Golemon [EMAIL PROTECTED] | +--+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.102 2008/01/08 19:09:12 iliaa Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.103 2008/07/11 18:34:43 felipe Exp $ */ #include php.h #include php_globals.h @@ -776,6 +776,13 @@ } php_stream_write_string(stream, TYPE I\r\n); /* we need this since some servers refuse to accept SIZE command in ASCII mode */ + + result = GET_FTP_RESULT(stream); + + if(result 200 || result 299) { + goto stat_errexit; + } + php_stream_printf(stream TSRMLS_CC, SIZE %s\r\n, (resource-path != NULL ? resource-path : /)); result = GET_FTP_RESULT(stream); if (result 200 || result 299) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard ftp_fopen_wrapper.c
iliaa Tue Jan 8 19:09:12 2008 UTC Modified files: /php-src/ext/standard ftp_fopen_wrapper.c Log: MFB: Fixed bug #43498 (file_exists() on a proftpd server got SIZE not allowed in ASCII mode). http://cvs.php.net/viewvc.cgi/php-src/ext/standard/ftp_fopen_wrapper.c?r1=1.101r2=1.102diff_format=u Index: php-src/ext/standard/ftp_fopen_wrapper.c diff -u php-src/ext/standard/ftp_fopen_wrapper.c:1.101 php-src/ext/standard/ftp_fopen_wrapper.c:1.102 --- php-src/ext/standard/ftp_fopen_wrapper.c:1.101 Mon Dec 31 07:12:15 2007 +++ php-src/ext/standard/ftp_fopen_wrapper.cTue Jan 8 19:09:12 2008 @@ -18,7 +18,7 @@ | Sara Golemon [EMAIL PROTECTED] | +--+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.101 2007/12/31 07:12:15 sebastian Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.102 2008/01/08 19:09:12 iliaa Exp $ */ #include php.h #include php_globals.h @@ -775,6 +775,7 @@ ssb-sb.st_mode |= S_IFDIR; } + php_stream_write_string(stream, TYPE I\r\n); /* we need this since some servers refuse to accept SIZE command in ASCII mode */ php_stream_printf(stream TSRMLS_CC, SIZE %s\r\n, (resource-path != NULL ? resource-path : /)); result = GET_FTP_RESULT(stream); if (result 200 || result 299) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard ftp_fopen_wrapper.c
janiSat Dec 29 18:46:10 2007 UTC Modified files: /php-src/ext/standard ftp_fopen_wrapper.c Log: - This makes no sense with non-ipv6 builds. (and fixes lot of issues with misconfigured servers) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/ftp_fopen_wrapper.c?r1=1.99r2=1.100diff_format=u Index: php-src/ext/standard/ftp_fopen_wrapper.c diff -u php-src/ext/standard/ftp_fopen_wrapper.c:1.99 php-src/ext/standard/ftp_fopen_wrapper.c:1.100 --- php-src/ext/standard/ftp_fopen_wrapper.c:1.99 Sun Sep 30 05:43:28 2007 +++ php-src/ext/standard/ftp_fopen_wrapper.cSat Dec 29 18:46:10 2007 @@ -18,7 +18,7 @@ | Sara Golemon [EMAIL PROTECTED] | +--+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.99 2007/09/30 05:43:28 jani Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.100 2007/12/29 18:46:10 jani Exp $ */ #include php.h #include php_globals.h @@ -300,19 +300,21 @@ /* {{{ php_fopen_do_pasv */ -static unsigned short php_fopen_do_pasv(php_stream *stream, char *ip, int ip_size, char **phoststart TSRMLS_DC) +static unsigned short php_fopen_do_pasv(php_stream *stream, char *ip, size_t ip_size, char **phoststart TSRMLS_DC) { char tmp_line[512]; int result, i; unsigned short portno; char *tpath, *ttpath, *hoststart=NULL; +#ifdef HAVE_IPV6 /* We try EPSV first, needed for IPv6 and works on some IPv4 servers */ php_stream_write_string(stream, EPSV\r\n); result = GET_FTP_RESULT(stream); /* check if we got a 229 response */ if (result != 229) { +#endif /* EPSV failed, let's try PASV */ php_stream_write_string(stream, PASV\r\n); result = GET_FTP_RESULT(stream); @@ -357,6 +359,7 @@ tpath++; /* pull out the LSB of the port */ portno += (unsigned short) strtoul(tpath, ttpath, 10); +#ifdef HAVE_IPV6 } else { /* parse epsv command (|||6446|) */ for (i = 0, tpath = tmp_line + 4; *tpath; tpath++) { @@ -372,6 +375,7 @@ /* pull out the port */ portno = (unsigned short) strtoul(tpath + 1, ttpath, 10); } +#endif if (ttpath == NULL) { /* didn't get correct response from EPSV/PASV */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard ftp_fopen_wrapper.c
janiThu Sep 27 13:16:09 2007 UTC Modified files: /php-src/ext/standard ftp_fopen_wrapper.c Log: MFB52: cs+ws (and synced the folding wrap style!) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/ftp_fopen_wrapper.c?r1=1.97r2=1.98diff_format=u Index: php-src/ext/standard/ftp_fopen_wrapper.c diff -u php-src/ext/standard/ftp_fopen_wrapper.c:1.97 php-src/ext/standard/ftp_fopen_wrapper.c:1.98 --- php-src/ext/standard/ftp_fopen_wrapper.c:1.97 Fri Sep 21 12:57:23 2007 +++ php-src/ext/standard/ftp_fopen_wrapper.cThu Sep 27 13:16:09 2007 @@ -18,7 +18,7 @@ | Sara Golemon [EMAIL PROTECTED] | +--+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.97 2007/09/21 12:57:23 tony2001 Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.98 2007/09/27 13:16:09 jani Exp $ */ #include php.h #include php_globals.h @@ -69,8 +69,12 @@ #include php_fopen_wrappers.h +#define FTPS_ENCRYPT_DATA 1 +#define GET_FTP_RESULT(stream) get_ftp_result((stream), tmp_line, sizeof(tmp_line) TSRMLS_CC) -static inline int get_ftp_result(php_stream *stream, char *buffer, size_t buffer_size TSRMLS_DC) /* {{{ */ +/* {{{ get_ftp_result + */ +static inline int get_ftp_result(php_stream *stream, char *buffer, size_t buffer_size TSRMLS_DC) { while (php_stream_gets(stream, ZSTR(buffer), buffer_size-1) !(isdigit((int) buffer[0]) isdigit((int) buffer[1]) @@ -78,11 +82,10 @@ return strtol(buffer, NULL, 10); } /* }}} */ -#define GET_FTP_RESULT(stream) get_ftp_result((stream), tmp_line, sizeof(tmp_line) TSRMLS_CC) -#define FTPS_ENCRYPT_DATA 1 - -static int php_stream_ftp_stream_stat(php_stream_wrapper *wrapper, php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC) /* {{{ */ +/* {{{ php_stream_ftp_stream_stat + */ +static int php_stream_ftp_stream_stat(php_stream_wrapper *wrapper, php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC) { /* For now, we return with a failure code to prevent the underlying * file's details from being used instead. */ @@ -90,7 +93,9 @@ } /* }}} */ -static int php_stream_ftp_stream_close(php_stream_wrapper *wrapper, php_stream *stream TSRMLS_DC) /* {{{ */ +/* {{{ php_stream_ftp_stream_close + */ +static int php_stream_ftp_stream_close(php_stream_wrapper *wrapper, php_stream *stream TSRMLS_DC) { php_stream *controlstream = (php_stream *)stream-wrapperdata; @@ -561,7 +566,7 @@ php_url_free(resource); return datastream; - errexit: +errexit: if (resource) { php_url_free(resource); } @@ -725,7 +730,7 @@ php_url_free(resource); return php_stream_alloc(php_ftp_dirstream_ops, datastream, 0, mode); - opendir_errexit: +opendir_errexit: if (resource) { php_url_free(resource); } @@ -825,7 +830,7 @@ #endif } else { /* error or unsupported command */ - mdtm_error: +mdtm_error: #ifdef NETWARE ssb-sb.st_mtime.tv_sec = -1; #else @@ -857,7 +862,7 @@ php_url_free(resource); return 0; - stat_errexit: +stat_errexit: if (resource) { php_url_free(resource); } @@ -907,7 +912,7 @@ php_stream_close(stream); return 1; - unlink_errexit: +unlink_errexit: if (resource) { php_url_free(resource); } @@ -983,7 +988,7 @@ php_stream_close(stream); return 1; - rename_errexit: +rename_errexit: if (resource_from) { php_url_free(resource_from); } @@ -1080,7 +1085,7 @@ return 1; - mkdir_errexit: +mkdir_errexit: if (resource) { php_url_free(resource); } @@ -1130,7 +1135,7 @@ return 1; - rmdir_errexit: +rmdir_errexit: if (resource) { php_url_free(resource); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard ftp_fopen_wrapper.c
tony2001Fri Sep 21 12:57:23 2007 UTC Modified files: /php-src/ext/standard ftp_fopen_wrapper.c Log: fix invalid read when opendir over FTP fails (coverity issue #462) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/ftp_fopen_wrapper.c?r1=1.96r2=1.97diff_format=u Index: php-src/ext/standard/ftp_fopen_wrapper.c diff -u php-src/ext/standard/ftp_fopen_wrapper.c:1.96 php-src/ext/standard/ftp_fopen_wrapper.c:1.97 --- php-src/ext/standard/ftp_fopen_wrapper.c:1.96 Fri Aug 31 07:41:45 2007 +++ php-src/ext/standard/ftp_fopen_wrapper.cFri Sep 21 12:57:23 2007 @@ -18,7 +18,7 @@ | Sara Golemon [EMAIL PROTECTED] | +--+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.96 2007/08/31 07:41:45 jani Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.97 2007/09/21 12:57:23 tony2001 Exp $ */ #include php.h #include php_globals.h @@ -666,6 +666,8 @@ char ip[sizeof(123.123.123.123)]; unsigned short portno; + tmp_line[0] = '\0'; + stream = php_ftp_fopen_connect(wrapper, path, mode, options, opened_path, context, reuseid, resource, use_ssl, use_ssl_on_data TSRMLS_CC); if (!stream) { goto opendir_errexit; @@ -731,8 +733,9 @@ php_stream_notify_error(context, PHP_STREAM_NOTIFY_FAILURE, tmp_line, result); php_stream_close(stream); } - if (tmp_line[0] != '\0') + if (tmp_line[0] != '\0') { php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, FTP server reports %s, tmp_line); + } return NULL; } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard ftp_fopen_wrapper.c
tony2001Mon Mar 20 14:10:23 2006 UTC Modified files: /php-src/ext/standard ftp_fopen_wrapper.c Log: fix buffer overrun http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/ftp_fopen_wrapper.c?r1=1.89r2=1.90diff_format=u Index: php-src/ext/standard/ftp_fopen_wrapper.c diff -u php-src/ext/standard/ftp_fopen_wrapper.c:1.89 php-src/ext/standard/ftp_fopen_wrapper.c:1.90 --- php-src/ext/standard/ftp_fopen_wrapper.c:1.89 Thu Mar 2 13:12:45 2006 +++ php-src/ext/standard/ftp_fopen_wrapper.cMon Mar 20 14:10:23 2006 @@ -18,7 +18,7 @@ | Sara Golemon [EMAIL PROTECTED] | +--+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.89 2006/03/02 13:12:45 dmitry Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.90 2006/03/20 14:10:23 tony2001 Exp $ */ #include php.h #include php_globals.h @@ -611,7 +611,7 @@ tmp_len = MIN(sizeof(ent-d_name), basename_len - 1); memcpy(ent-d_name, basename, tmp_len); - ent-d_name[tmp_len] = '\0'; + ent-d_name[tmp_len - 1] = '\0'; efree(basename); /* Trim off trailing whitespace characters */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard ftp_fopen_wrapper.c
iliaa Mon Nov 21 22:01:59 2005 EDT Modified files: /php-src/ext/standard ftp_fopen_wrapper.c Log: MFB51: Fixed command error in ftp:// wrapper. http://cvs.php.net/diff.php/php-src/ext/standard/ftp_fopen_wrapper.c?r1=1.86r2=1.87ty=u Index: php-src/ext/standard/ftp_fopen_wrapper.c diff -u php-src/ext/standard/ftp_fopen_wrapper.c:1.86 php-src/ext/standard/ftp_fopen_wrapper.c:1.87 --- php-src/ext/standard/ftp_fopen_wrapper.c:1.86 Tue Oct 11 10:33:14 2005 +++ php-src/ext/standard/ftp_fopen_wrapper.cMon Nov 21 22:01:59 2005 @@ -18,7 +18,7 @@ | Sara Golemon [EMAIL PROTECTED] | +--+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.86 2005/10/11 14:33:14 iliaa Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.87 2005/11/22 03:01:59 iliaa Exp $ */ #include php.h #include php_globals.h @@ -513,13 +513,13 @@ } /* retrieve file */ - memcpy(tmp_line, RETR, 4); + memcpy(tmp_line, RETR, sizeof(RETR)); } else if (read_write == 2) { /* Write new file */ - memcpy(tmp_line, STOR, 4); + memcpy(tmp_line, STOR, sizeof(STOR)); } else { /* Append */ - memcpy(tmp_line, APPE, 4); + memcpy(tmp_line, APPE, sizeof(APPE)); } php_stream_printf(stream TSRMLS_CC, %s %s\r\n, tmp_line, (resource-path != NULL ? resource-path : /)); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard ftp_fopen_wrapper.c
iliaa Tue Oct 11 10:33:16 2005 EDT Modified files: /php-src/ext/standard ftp_fopen_wrapper.c Log: Fixed bug #34742 (ftp wrapper failures caused from segmented command transfer). http://cvs.php.net/diff.php/php-src/ext/standard/ftp_fopen_wrapper.c?r1=1.85r2=1.86ty=u Index: php-src/ext/standard/ftp_fopen_wrapper.c diff -u php-src/ext/standard/ftp_fopen_wrapper.c:1.85 php-src/ext/standard/ftp_fopen_wrapper.c:1.86 --- php-src/ext/standard/ftp_fopen_wrapper.c:1.85 Wed Aug 3 10:08:01 2005 +++ php-src/ext/standard/ftp_fopen_wrapper.cTue Oct 11 10:33:14 2005 @@ -18,7 +18,7 @@ | Sara Golemon [EMAIL PROTECTED] | +--+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.85 2005/08/03 14:08:01 sniper Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.86 2005/10/11 14:33:14 iliaa Exp $ */ #include php.h #include php_globals.h @@ -221,17 +221,15 @@ } /* send the user name */ - php_stream_write_string(stream, USER ); if (resource-user != NULL) { tmp_len = php_raw_url_decode(resource-user, strlen(resource-user)); PHP_FTP_CNTRL_CHK(resource-user, tmp_len, Invalid login %s) - php_stream_write_string(stream, resource-user); + php_stream_printf(stream TSRMLS_CC, USER %s\r\n, resource-user); } else { - php_stream_write_string(stream, anonymous); + php_stream_write_string(stream, USER anonymous\r\n); } - php_stream_write_string(stream, \r\n); /* get the response */ result = GET_FTP_RESULT(stream); @@ -240,24 +238,22 @@ if (result = 300 result = 399) { php_stream_notify_info(context, PHP_STREAM_NOTIFY_AUTH_REQUIRED, tmp_line, 0); - php_stream_write_string(stream, PASS ); if (resource-pass != NULL) { tmp_len = php_raw_url_decode(resource-pass, strlen(resource-pass)); PHP_FTP_CNTRL_CHK(resource-pass, tmp_len, Invalid password %s) - php_stream_write_string(stream, resource-pass); + php_stream_printf(stream TSRMLS_CC, PASS %s\r\n, resource-pass); } else { /* if the user has configured who they are, send that as the password */ if (cfg_get_string(from, scratch) == SUCCESS) { - php_stream_write_string(stream, scratch); + php_stream_printf(stream TSRMLS_CC, PASS %s\r\n, scratch); } else { - php_stream_write_string(stream, anonymous); + php_stream_write_string(stream, PASS anonymous\r\n); } } - php_stream_write_string(stream, \r\n); - + /* read the response */ result = GET_FTP_RESULT(stream); @@ -452,9 +448,7 @@ goto errexit; /* find out the size of the file (verifying it exists) */ - php_stream_write_string(stream, SIZE ); - php_stream_write_string(stream, resource-path); - php_stream_write_string(stream, \r\n); + php_stream_printf(stream TSRMLS_CC, SIZE %s\r\n, resource-path); /* read the response */ result = GET_FTP_RESULT(stream); @@ -483,9 +477,7 @@ if (allow_overwrite) { /* Context permits overwritting file, so we just delete whatever's there in preparation */ - php_stream_write_string(stream, DELE ); - php_stream_write_string(stream, resource-path); - php_stream_write_string(stream, \r\n); + php_stream_printf(stream TSRMLS_CC, DELE %s\r\n, resource-path); result = GET_FTP_RESULT(stream); if (result = 300 || result = 199) { goto errexit; @@ -512,8 +504,7 @@ php_stream_context_get_option(context, ftp, resume_pos, tmpzval) == SUCCESS Z_TYPE_PP(tmpzval) == IS_LONG Z_LVAL_PP(tmpzval) 0) { - snprintf(tmp_line, 511, REST %ld\r\n, Z_LVAL_PP(tmpzval)); - php_stream_write_string(stream, tmp_line); + php_stream_printf(stream TSRMLS_CC, REST %ld\r\n, Z_LVAL_PP(tmpzval)); result = GET_FTP_RESULT(stream); if (result 300 || result 399) { php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, Unable to
[PHP-CVS] cvs: php-src /ext/standard ftp_fopen_wrapper.c
pollita Fri Jul 15 11:45:45 2005 EDT Modified files: /php-src/ext/standard ftp_fopen_wrapper.c Log: Pass context parameter through to xport_create http://cvs.php.net/diff.php/php-src/ext/standard/ftp_fopen_wrapper.c?r1=1.83r2=1.84ty=u Index: php-src/ext/standard/ftp_fopen_wrapper.c diff -u php-src/ext/standard/ftp_fopen_wrapper.c:1.83 php-src/ext/standard/ftp_fopen_wrapper.c:1.84 --- php-src/ext/standard/ftp_fopen_wrapper.c:1.83 Wed Jul 13 19:28:22 2005 +++ php-src/ext/standard/ftp_fopen_wrapper.cFri Jul 15 11:45:43 2005 @@ -18,7 +18,7 @@ | Sara Golemon [EMAIL PROTECTED] | +--+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.83 2005/07/13 23:28:22 pollita Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.84 2005/07/15 15:45:43 pollita Exp $ */ #include php.h #include php_globals.h @@ -133,7 +133,7 @@ resource-port = 21; transport_len = spprintf(transport, 0, tcp://%s:%d, resource-host, resource-port); - stream = php_stream_xport_create(transport, transport_len, REPORT_ERRORS, STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT, NULL, NULL, NULL, NULL, NULL); + stream = php_stream_xport_create(transport, transport_len, REPORT_ERRORS, STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT, NULL, NULL, context, NULL, NULL); efree(transport); if (stream == NULL) { result = 0; /* silence */ @@ -542,7 +542,7 @@ hoststart = resource-host; } transport_len = spprintf(transport, 0, tcp://%s:%d, hoststart, portno); - datastream = php_stream_xport_create(transport, transport_len, REPORT_ERRORS, STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT, NULL, NULL, NULL, NULL, NULL); + datastream = php_stream_xport_create(transport, transport_len, REPORT_ERRORS, STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT, NULL, NULL, context, NULL, NULL); efree(transport); if (datastream == NULL) { goto errexit; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard ftp_fopen_wrapper.c
pollita Wed Jul 13 19:28:24 2005 EDT Modified files: /php-src/ext/standard ftp_fopen_wrapper.c Log: Route ftp:// wrapper via transports layer.\nFix typo in datastream crypto startup http://cvs.php.net/diff.php/php-src/ext/standard/ftp_fopen_wrapper.c?r1=1.82r2=1.83ty=u Index: php-src/ext/standard/ftp_fopen_wrapper.c diff -u php-src/ext/standard/ftp_fopen_wrapper.c:1.82 php-src/ext/standard/ftp_fopen_wrapper.c:1.83 --- php-src/ext/standard/ftp_fopen_wrapper.c:1.82 Sat May 7 12:07:59 2005 +++ php-src/ext/standard/ftp_fopen_wrapper.cWed Jul 13 19:28:22 2005 @@ -18,7 +18,7 @@ | Sara Golemon [EMAIL PROTECTED] | +--+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.82 2005/05/07 16:07:59 iliaa Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.83 2005/07/13 23:28:22 pollita Exp $ */ #include php.h #include php_globals.h @@ -115,6 +115,8 @@ int result, use_ssl, use_ssl_on_data = 0, tmp_len; char *scratch; char tmp_line[512]; + char *transport; + int transport_len; resource = php_url_parse(path); if (resource == NULL || resource-path == NULL) { @@ -130,7 +132,9 @@ if (resource-port == 0) resource-port = 21; - stream = php_stream_sock_open_host(resource-host, resource-port, SOCK_STREAM, NULL, 0); + transport_len = spprintf(transport, 0, tcp://%s:%d, resource-host, resource-port); + stream = php_stream_xport_create(transport, transport_len, REPORT_ERRORS, STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT, NULL, NULL, NULL, NULL, NULL); + efree(transport); if (stream == NULL) { result = 0; /* silence */ goto connect_errexit; @@ -399,6 +403,8 @@ zval **tmpzval; int allow_overwrite = 0; int read_write = 0; + char *transport; + int transport_len; tmp_line[0] = '\0'; @@ -535,7 +541,9 @@ if (hoststart == NULL) { hoststart = resource-host; } - datastream = php_stream_sock_open_host(hoststart, portno, SOCK_STREAM, 0, 0); + transport_len = spprintf(transport, 0, tcp://%s:%d, hoststart, portno); + datastream = php_stream_xport_create(transport, transport_len, REPORT_ERRORS, STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT, NULL, NULL, NULL, NULL, NULL); + efree(transport); if (datastream == NULL) { goto errexit; } @@ -553,9 +561,9 @@ php_stream_context_set(datastream, context); php_stream_notify_progress_init(context, 0, file_size); - if (use_ssl_on_data (php_stream_xport_crypto_setup(stream, + if (use_ssl_on_data (php_stream_xport_crypto_setup(datastream, STREAM_CRYPTO_METHOD_SSLv23_CLIENT, NULL TSRMLS_CC) 0 || - php_stream_xport_crypto_enable(stream, 1 TSRMLS_CC) 0)) { + php_stream_xport_crypto_enable(datastream, 1 TSRMLS_CC) 0)) { php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, Unable to activate SSL mode); php_stream_close(datastream); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard ftp_fopen_wrapper.c
iliaa Sat May 7 12:07:59 2005 EDT Modified files: /php-src/ext/standard ftp_fopen_wrapper.c Log: MFB: Fixed memory leak on error in FTP wrapper. http://cvs.php.net/diff.php/php-src/ext/standard/ftp_fopen_wrapper.c?r1=1.81r2=1.82ty=u Index: php-src/ext/standard/ftp_fopen_wrapper.c diff -u php-src/ext/standard/ftp_fopen_wrapper.c:1.81 php-src/ext/standard/ftp_fopen_wrapper.c:1.82 --- php-src/ext/standard/ftp_fopen_wrapper.c:1.81 Fri May 6 14:42:52 2005 +++ php-src/ext/standard/ftp_fopen_wrapper.cSat May 7 12:07:59 2005 @@ -18,7 +18,7 @@ | Sara Golemon [EMAIL PROTECTED] | +--+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.81 2005/05/06 18:42:52 iliaa Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.82 2005/05/07 16:07:59 iliaa Exp $ */ #include php.h #include php_globals.h @@ -112,7 +112,7 @@ { php_stream *stream = NULL, *reuseid = NULL; php_url *resource = NULL; - int result, use_ssl, use_ssl_on_data = 0; + int result, use_ssl, use_ssl_on_data = 0, tmp_len; char *scratch; char tmp_line[512]; @@ -205,23 +205,24 @@ #endif } +#define PHP_FTP_CNTRL_CHK(val, val_len, err_msg) { \ + unsigned char *s = val, *e = s + val_len; \ + while (s e) { \ + if (iscntrl(*s)) { \ + php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, err_msg, val); \ + goto connect_errexit; \ + } \ + s++;\ + } \ +} + /* send the user name */ php_stream_write_string(stream, USER ); if (resource-user != NULL) { - unsigned char *s, *e; - int user_len = php_raw_url_decode(resource-user, strlen(resource-user)); - - s = resource-user; - e = s + user_len; - /* check for control characters that should not be present in the user name */ - while (s e) { - if (iscntrl(*s)) { - php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, Invalid login %s, resource-user); - goto connect_errexit; - } - s++; - } - + tmp_len = php_raw_url_decode(resource-user, strlen(resource-user)); + + PHP_FTP_CNTRL_CHK(resource-user, tmp_len, Invalid login %s) + php_stream_write_string(stream, resource-user); } else { php_stream_write_string(stream, anonymous); @@ -237,7 +238,10 @@ php_stream_write_string(stream, PASS ); if (resource-pass != NULL) { - php_raw_url_decode(resource-pass, strlen(resource-pass)); + tmp_len = php_raw_url_decode(resource-pass, strlen(resource-pass)); + + PHP_FTP_CNTRL_CHK(resource-pass, tmp_len, Invalid password %s) + php_stream_write_string(stream, resource-pass); } else { /* if the user has configured who they are, @@ -278,7 +282,11 @@ return stream; - connect_errexit: +connect_errexit: + if (resource) { + php_url_free(resource); + } + if (stream) { php_stream_close(stream); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard ftp_fopen_wrapper.c
iliaa Fri May 6 14:42:53 2005 EDT Modified files: /php-src/ext/standard ftp_fopen_wrapper.c Log: Check ftp user name for control characters. http://cvs.php.net/diff.php/php-src/ext/standard/ftp_fopen_wrapper.c?r1=1.80r2=1.81ty=u Index: php-src/ext/standard/ftp_fopen_wrapper.c diff -u php-src/ext/standard/ftp_fopen_wrapper.c:1.80 php-src/ext/standard/ftp_fopen_wrapper.c:1.81 --- php-src/ext/standard/ftp_fopen_wrapper.c:1.80 Sun Feb 27 12:08:18 2005 +++ php-src/ext/standard/ftp_fopen_wrapper.cFri May 6 14:42:52 2005 @@ -18,7 +18,7 @@ | Sara Golemon [EMAIL PROTECTED] | +--+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.80 2005/02/27 17:08:18 iliaa Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.81 2005/05/06 18:42:52 iliaa Exp $ */ #include php.h #include php_globals.h @@ -208,7 +208,20 @@ /* send the user name */ php_stream_write_string(stream, USER ); if (resource-user != NULL) { - php_raw_url_decode(resource-user, strlen(resource-user)); + unsigned char *s, *e; + int user_len = php_raw_url_decode(resource-user, strlen(resource-user)); + + s = resource-user; + e = s + user_len; + /* check for control characters that should not be present in the user name */ + while (s e) { + if (iscntrl(*s)) { + php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, Invalid login %s, resource-user); + goto connect_errexit; + } + s++; + } + php_stream_write_string(stream, resource-user); } else { php_stream_write_string(stream, anonymous); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard ftp_fopen_wrapper.c image.c
iliaa Sun Feb 27 12:08:18 2005 EDT Modified files: /php-src/ext/standard image.c ftp_fopen_wrapper.c Log: Fixed compiler warnings. http://cvs.php.net/diff.php/php-src/ext/standard/image.c?r1=1.107r2=1.108ty=u Index: php-src/ext/standard/image.c diff -u php-src/ext/standard/image.c:1.107 php-src/ext/standard/image.c:1.108 --- php-src/ext/standard/image.c:1.107 Thu Feb 24 15:22:40 2005 +++ php-src/ext/standard/image.cSun Feb 27 12:08:18 2005 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: image.c,v 1.107 2005/02/24 20:22:40 helly Exp $ */ +/* $Id: image.c,v 1.108 2005/02/27 17:08:18 iliaa Exp $ */ #include php.h #include stdio.h @@ -601,7 +601,7 @@ { struct gfxinfo *result = NULL; unsigned short dummy_short; - int dummy_int, highest_bit_depth, bit_depth; + int highest_bit_depth, bit_depth; unsigned char first_marker_id; unsigned int i; http://cvs.php.net/diff.php/php-src/ext/standard/ftp_fopen_wrapper.c?r1=1.79r2=1.80ty=u Index: php-src/ext/standard/ftp_fopen_wrapper.c diff -u php-src/ext/standard/ftp_fopen_wrapper.c:1.79 php-src/ext/standard/ftp_fopen_wrapper.c:1.80 --- php-src/ext/standard/ftp_fopen_wrapper.c:1.79 Wed Sep 29 06:21:41 2004 +++ php-src/ext/standard/ftp_fopen_wrapper.cSun Feb 27 12:08:18 2005 @@ -18,7 +18,7 @@ | Sara Golemon [EMAIL PROTECTED] | +--+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.79 2004/09/29 10:21:41 hyanantha Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.80 2005/02/27 17:08:18 iliaa Exp $ */ #include php.h #include php_globals.h @@ -648,7 +648,7 @@ { php_stream *stream, *reuseid, *datastream = NULL; php_url *resource = NULL; - int result, use_ssl, use_ssl_on_data = 0; + int result = 0, use_ssl, use_ssl_on_data = 0; char *hoststart = NULL, tmp_line[512]; char ip[sizeof(123.123.123.123)]; unsigned short portno; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard ftp_fopen_wrapper.c
hyanantha Wed Sep 29 06:21:44 2004 EDT Modified files: /php-src/ext/standard ftp_fopen_wrapper.c Log: removed unwanted comments, NEW_LIBC checks and NetWare specific stat structure population http://cvs.php.net/diff.php/php-src/ext/standard/ftp_fopen_wrapper.c?r1=1.78r2=1.79ty=u Index: php-src/ext/standard/ftp_fopen_wrapper.c diff -u php-src/ext/standard/ftp_fopen_wrapper.c:1.78 php-src/ext/standard/ftp_fopen_wrapper.c:1.79 --- php-src/ext/standard/ftp_fopen_wrapper.c:1.78 Sun Aug 15 21:41:14 2004 +++ php-src/ext/standard/ftp_fopen_wrapper.cWed Sep 29 06:21:41 2004 @@ -18,7 +18,7 @@ | Sara Golemon [EMAIL PROTECTED] | +--+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.78 2004/08/16 01:41:14 iliaa Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.79 2004/09/29 10:21:41 hyanantha Exp $ */ #include php.h #include php_globals.h @@ -35,14 +35,6 @@ #include winsock2.h #define O_RDONLY _O_RDONLY #include win32/param.h -#elif defined(NETWARE) -/*#include ws2nlm.h*/ -/*#include sys/socket.h*/ -#ifdef NEW_LIBC -#include sys/param.h -#else -#include netware/param.h -#endif #else #include sys/param.h #endif @@ -57,7 +49,6 @@ #ifdef PHP_WIN32 #include winsock2.h #elif defined(NETWARE) defined(USE_WINSOCK) -/*#include ws2nlm.h*/ #include novsock2.h #else #include netinet/in.h @@ -828,19 +819,33 @@ tm.tm_sec += stamp - mktime(gmt); tm.tm_isdst = gmt-tm_isdst; +#ifdef NETWARE + ssb-sb.st_mtime.tv_sec = mktime(tm); +#else ssb-sb.st_mtime = mktime(tm); +#endif } else { /* error or unsupported command */ mdtm_error: +#ifdef NETWARE + ssb-sb.st_mtime.tv_sec = -1; +#else ssb-sb.st_mtime = -1; +#endif } ssb-sb.st_ino = 0; /* Unknown values */ ssb-sb.st_dev = 0; ssb-sb.st_uid = 0; ssb-sb.st_gid = 0; +#ifdef NETWARE + ssb-sb.st_atime.tv_sec = -1; + ssb-sb.st_ctime.tv_sec = -1; +#else ssb-sb.st_atime = -1; ssb-sb.st_ctime = -1; +#endif + ssb-sb.st_nlink = 1; ssb-sb.st_rdev = -1; #ifdef HAVE_ST_BLKSIZE -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard ftp_fopen_wrapper.c
iliaa Sun Aug 15 21:41:15 2004 EDT Modified files: /php-src/ext/standard ftp_fopen_wrapper.c Log: Fixed bug #29678 (opendir() with ftp:// wrapper segfaults if path does not have trailing slash). http://cvs.php.net/diff.php/php-src/ext/standard/ftp_fopen_wrapper.c?r1=1.77r2=1.78ty=u Index: php-src/ext/standard/ftp_fopen_wrapper.c diff -u php-src/ext/standard/ftp_fopen_wrapper.c:1.77 php-src/ext/standard/ftp_fopen_wrapper.c:1.78 --- php-src/ext/standard/ftp_fopen_wrapper.c:1.77 Sat Jul 24 00:14:26 2004 +++ php-src/ext/standard/ftp_fopen_wrapper.cSun Aug 15 21:41:14 2004 @@ -18,7 +18,7 @@ | Sara Golemon [EMAIL PROTECTED] | +--+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.77 2004/07/24 04:14:26 pollita Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.78 2004/08/16 01:41:14 iliaa Exp $ */ #include php.h #include php_globals.h @@ -126,8 +126,12 @@ char tmp_line[512]; resource = php_url_parse(path); - if (resource == NULL || resource-path == NULL) + if (resource == NULL || resource-path == NULL) { + if (resource presource) { + *presource = resource; + } return NULL; + } use_ssl = resource-scheme (strlen(resource-scheme) 3) resource-scheme[3] == 's'; @@ -659,6 +663,9 @@ unsigned short portno; stream = php_ftp_fopen_connect(wrapper, path, mode, options, opened_path, context, reuseid, resource, use_ssl, use_ssl_on_data TSRMLS_CC); + if (!stream) { + goto opendir_errexit; + } /* set the connection to be ascii */ php_stream_write_string(stream, TYPE A\r\n); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard ftp_fopen_wrapper.c
pollita Sat Jul 24 00:14:26 2004 EDT Modified files: /php-src/ext/standard ftp_fopen_wrapper.c Log: Oh by the way, only use proxy mode for reading... http://cvs.php.net/diff.php/php-src/ext/standard/ftp_fopen_wrapper.c?r1=1.76r2=1.77ty=u Index: php-src/ext/standard/ftp_fopen_wrapper.c diff -u php-src/ext/standard/ftp_fopen_wrapper.c:1.76 php-src/ext/standard/ftp_fopen_wrapper.c:1.77 --- php-src/ext/standard/ftp_fopen_wrapper.c:1.76 Sat Jul 24 00:01:48 2004 +++ php-src/ext/standard/ftp_fopen_wrapper.cSat Jul 24 00:14:26 2004 @@ -18,7 +18,7 @@ | Sara Golemon [EMAIL PROTECTED] | +--+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.76 2004/07/24 04:01:48 pollita Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.77 2004/07/24 04:14:26 pollita Exp $ */ #include php.h #include php_globals.h @@ -384,12 +384,6 @@ int allow_overwrite = 0; int read_write = 0; - if (context - php_stream_context_get_option(context, ftp, proxy, tmpzval) == SUCCESS) { - /* Use http wrapper to proxy ftp request */ - return php_stream_url_wrap_http(wrapper, path, mode, options, opened_path, context STREAMS_CC TSRMLS_CC); - } - tmp_line[0] = '\0'; if (strpbrk(mode, r+)) { @@ -410,6 +404,18 @@ /* No mode specified? */ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, Unknown file open mode.); return NULL; + } + + if (context + php_stream_context_get_option(context, ftp, proxy, tmpzval) == SUCCESS) { + if (read_write == 1) { + /* Use http wrapper to proxy ftp request */ + return php_stream_url_wrap_http(wrapper, path, mode, options, opened_path, context STREAMS_CC TSRMLS_CC); + } else { + /* ftp proxy is read-only */ + php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, FTP proxy may only be used in read mode); + return NULL; + } } stream = php_ftp_fopen_connect(wrapper, path, mode, options, opened_path, context, reuseid, resource, use_ssl, use_ssl_on_data TSRMLS_CC); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard ftp_fopen_wrapper.c
pollita Mon May 17 16:31:59 2004 EDT Modified files: /php-src/ext/standard ftp_fopen_wrapper.c Log: BugFix# 27982: Provide error message when trying to overwrite an existant file without overwrite context option. http://cvs.php.net/diff.php/php-src/ext/standard/ftp_fopen_wrapper.c?r1=1.73r2=1.74ty=u Index: php-src/ext/standard/ftp_fopen_wrapper.c diff -u php-src/ext/standard/ftp_fopen_wrapper.c:1.73 php-src/ext/standard/ftp_fopen_wrapper.c:1.74 --- php-src/ext/standard/ftp_fopen_wrapper.c:1.73 Wed Jan 28 17:50:12 2004 +++ php-src/ext/standard/ftp_fopen_wrapper.cMon May 17 16:31:59 2004 @@ -18,7 +18,7 @@ | Sara Golemon [EMAIL PROTECTED] | +--+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.73 2004/01/28 22:50:12 pollita Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.74 2004/05/17 20:31:59 pollita Exp $ */ #include php.h #include php_globals.h @@ -457,6 +457,7 @@ goto errexit; } } else { + php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, Remote file already exists and overwrite context option not specified.); errno = EEXIST; goto errexit; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard ftp_fopen_wrapper.c
pollita Wed Jan 28 17:50:14 2004 EDT Modified files: /php-src/ext/standard ftp_fopen_wrapper.c Log: FTP dirstream_read should not leave whitespace/newlines on dirents http://cvs.php.net/diff.php/php-src/ext/standard/ftp_fopen_wrapper.c?r1=1.72r2=1.73ty=u Index: php-src/ext/standard/ftp_fopen_wrapper.c diff -u php-src/ext/standard/ftp_fopen_wrapper.c:1.72 php-src/ext/standard/ftp_fopen_wrapper.c:1.73 --- php-src/ext/standard/ftp_fopen_wrapper.c:1.72 Sat Jan 24 19:30:50 2004 +++ php-src/ext/standard/ftp_fopen_wrapper.cWed Jan 28 17:50:12 2004 @@ -18,7 +18,7 @@ | Sara Golemon [EMAIL PROTECTED] | +--+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.72 2004/01/25 00:30:50 abies Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.73 2004/01/28 22:50:12 pollita Exp $ */ #include php.h #include php_globals.h @@ -586,11 +586,19 @@ return 0; } - tmp_len = MIN(sizeof(ent-d_name), basename_len) - 1; + tmp_len = MIN(sizeof(ent-d_name), basename_len - 1); memcpy(ent-d_name, basename, tmp_len); ent-d_name[tmp_len] = '\0'; efree(basename); + /* Trim off trailing whitespace characters */ + tmp_len--; + while (tmp_len = 0 + (ent-d_name[tmp_len] == '\n' || ent-d_name[tmp_len] == '\r' || +ent-d_name[tmp_len] == '\t' || ent-d_name[tmp_len] == ' ')) { + ent-d_name[tmp_len--] = '\0'; + } + return sizeof(php_stream_dirent); } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard ftp_fopen_wrapper.c url.c url.h
abies Sat Jan 24 19:30:52 2004 EDT Modified files: /php-src/ext/standard url.c url.h ftp_fopen_wrapper.c Log: Changed prototypes to allow parsing of string literals and constant strings Minor CS/WS http://cvs.php.net/diff.php/php-src/ext/standard/url.c?r1=1.75r2=1.76ty=u Index: php-src/ext/standard/url.c diff -u php-src/ext/standard/url.c:1.75 php-src/ext/standard/url.c:1.76 --- php-src/ext/standard/url.c:1.75 Thu Jan 8 03:17:34 2004 +++ php-src/ext/standard/url.c Sat Jan 24 19:30:49 2004 @@ -15,7 +15,7 @@ | Author: Jim Winstead [EMAIL PROTECTED] | +--+ */ -/* $Id: url.c,v 1.75 2004/01/08 08:17:34 andi Exp $ */ +/* $Id: url.c,v 1.76 2004/01/25 00:30:49 abies Exp $ */ #include stdlib.h #include string.h @@ -83,12 +83,12 @@ /* {{{ php_url_parse */ -PHPAPI php_url *php_url_parse(char *str) +PHPAPI php_url *php_url_parse(char const *str) { int length = strlen(str); char port_buf[5]; php_url *ret = ecalloc(1, sizeof(php_url)); - char *s, *e, *p, *pp, *ue; + char const *s, *e, *p, *pp, *ue; s = str; ue = s + length; @@ -371,11 +371,11 @@ /* {{{ php_url_encode */ -PHPAPI char *php_url_encode(char *s, int len, int *new_length) +PHPAPI char *php_url_encode(char const *s, int len, int *new_length) { register unsigned char c; - unsigned char *to, *from, *start; - unsigned char *end; + unsigned char *to, *start; + unsigned char const *from, *end; from = s; end = s + len; @@ -392,15 +392,15 @@ (c 'Z' c 'a' c != '_') || (c 'z')) { to[0] = '%'; - to[1] = hexchars[(unsigned char) c 4]; - to[2] = hexchars[(unsigned char) c 15]; + to[1] = hexchars[c 4]; + to[2] = hexchars[c 15]; to += 3; #else /*CHARSET_EBCDIC*/ } else if (!isalnum(c) strchr(_-., c) == NULL) { /* Allow only alphanumeric chars and '_', '-', '.'; escape the rest */ to[0] = '%'; - to[1] = hexchars[os_toascii[(unsigned char) c] 4]; - to[2] = hexchars[os_toascii[(unsigned char) c] 15]; + to[1] = hexchars[os_toascii[c] 4]; + to[2] = hexchars[os_toascii[c] 15]; to += 3; #endif /*CHARSET_EBCDIC*/ } else { @@ -459,9 +459,11 @@ char *data = str; while (len--) { - if (*data == '+') + if (*data == '+') { *dest = ' '; - else if (*data == '%' len = 2 isxdigit((int) *(data + 1)) isxdigit((int) *(data + 2))) { + } + else if (*data == '%' len = 2 isxdigit((int) *(data + 1)) isxdigit((int) *(data + 2))) + { #ifndef CHARSET_EBCDIC *dest = (char) php_htoi(data + 1); #else @@ -469,8 +471,9 @@ #endif data += 2; len -= 2; - } else + } else { *dest = *data; + } data++; dest++; } @@ -481,7 +484,7 @@ /* {{{ php_raw_url_encode */ -PHPAPI char *php_raw_url_encode(char *s, int len, int *new_length) +PHPAPI char *php_raw_url_encode(char const *s, int len, int *new_length) { register int x, y; unsigned char *str; @@ -557,7 +560,8 @@ char *data = str; while (len--) { - if (*data == '%' len = 2 isxdigit((int) *(data + 1)) isxdigit((int) *(data + 2))) { + if (*data == '%' len = 2 isxdigit((int) *(data + 1)) isxdigit((int) *(data + 2))) + { #ifndef CHARSET_EBCDIC *dest = (char) php_htoi(data + 1); #else @@ -565,8 +569,9 @@ #endif data += 2; len -= 2; - } else + } else { *dest = *data; + } data++; dest++; } http://cvs.php.net/diff.php/php-src/ext/standard/url.h?r1=1.17r2=1.18ty=u Index: php-src/ext/standard/url.h diff -u php-src/ext/standard/url.h:1.17 php-src/ext/standard/url.h:1.18 --- php-src/ext/standard/url.h:1.17 Thu Jan 8 12:32:52 2004 +++ php-src/ext/standard/url.h Sat Jan 24 19:30:49 2004 @@ -15,7 +15,7 @@ | Author: Jim Winstead [EMAIL PROTECTED] | +--+ */ -/* $Id: url.h,v 1.17 2004/01/08 17:32:52 sniper Exp $ */ +/* $Id: url.h,v 1.18 2004/01/25 00:30:49 abies Exp $ */ #ifndef
Re: [PHP-CVS] cvs: php-src /ext/standard ftp_fopen_wrapper.c php_string.h string.c
Initially IsDBCSLeadByte() patch was introduced by Rui some time ago, but this hasn't worked as expected so far. So I think the best way to go at the time being is revert the patch, however it won't solve the issue at all. Indeed I can backport the patch in HEAD, but it might be so big that it wouldn't appear applicable to the stable branch. So I'm just trying to find a compromise. What do you think of this? Moriyoshi On 2003/12/12, at 8:16, Jani Taskinen wrote: No MFH? Bug still open? What's the deal here? --Jani On Wed, 10 Dec 2003, Moriyoshi Koizumi wrote: moriyoshi Wed Dec 10 02:15:29 2003 EDT Modified files: /php-src/ext/standard ftp_fopen_wrapper.c php_string.h string.c Log: Fix bug #26574 (basename() doesn't work properly with multibyte characters) Index: php-src/ext/standard/ftp_fopen_wrapper.c diff -u php-src/ext/standard/ftp_fopen_wrapper.c:1.66 php-src/ext/standard/ftp_fopen_wrapper.c:1.67 --- php-src/ext/standard/ftp_fopen_wrapper.c:1.66 Sat Nov 29 15:01:00 2003 +++ php-src/ext/standard/ftp_fopen_wrapper.c Wed Dec 10 02:15:28 2003 @@ -18,7 +18,7 @@ | Sara Golemon [EMAIL PROTECTED] | +- -+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.66 2003/11/29 20:01:00 pollita Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.67 2003/12/10 07:15:28 moriyoshi Exp $ */ #include php.h #include php_globals.h @@ -562,7 +562,7 @@ php_stream *innerstream = (php_stream *)stream-abstract; size_t tmp_len; char *basename; - int basename_len; + size_t basename_len; if (count != sizeof(php_stream_dirent)) { return 0; @@ -586,8 +586,9 @@ return 0; } - memcpy(ent-d_name, basename, MIN((int)sizeof(ent-d_name), basename_len)-1); - ent-d_name[sizeof(ent-d_name)-1] = '\0'; + tmp_len = MIN(sizeof(ent-d_name), basename_len) - 1; + memcpy(ent-d_name, basename, tmp_len); + ent-d_name[tmp_len] = '\0'; efree(basename); return sizeof(php_stream_dirent); Index: php-src/ext/standard/php_string.h diff -u php-src/ext/standard/php_string.h:1.81 php-src/ext/standard/php_string.h:1.82 --- php-src/ext/standard/php_string.h:1.81 Wed Dec 10 01:08:39 2003 +++ php-src/ext/standard/php_string.h Wed Dec 10 02:15:28 2003 @@ -17,7 +17,7 @@ +- -+ */ -/* $Id: php_string.h,v 1.81 2003/12/10 06:08:39 moriyoshi Exp $ */ +/* $Id: php_string.h,v 1.82 2003/12/10 07:15:28 moriyoshi Exp $ */ /* Synced with php 3.0 revision 1.43 1999-06-16 [ssb] */ @@ -122,7 +122,7 @@ PHPAPI char *php_addcslashes(char *str, int length, int *new_length, int freeit, char *what, int wlength TSRMLS_DC); PHPAPI void php_stripslashes(char *str, int *len TSRMLS_DC); PHPAPI void php_stripcslashes(char *str, int *len); -PHPAPI void php_basename(char *str, size_t len , char *suffix, size_t sufflen, char **p_ret, int *p_len); +PHPAPI void php_basename(char *str, size_t len , char *suffix, size_t sufflen, char **p_ret, size_t *p_len); PHPAPI size_t php_dirname(char *str, size_t len); PHPAPI char *php_stristr(unsigned char *s, unsigned char *t, size_t s_len, size_t t_len); PHPAPI char *php_str_to_str_ex(char *haystack, int length, char *needle, Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.405 php-src/ext/standard/string.c:1.406 --- php-src/ext/standard/string.c:1.405 Wed Dec 10 01:04:15 2003 +++ php-src/ext/standard/string.c Wed Dec 10 02:15:28 2003 @@ -18,7 +18,7 @@ +- -+ */ -/* $Id: string.c,v 1.405 2003/12/10 06:04:15 moriyoshi Exp $ */ +/* $Id: string.c,v 1.406 2003/12/10 07:15:28 moriyoshi Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -1068,56 +1068,69 @@ /* {{{ php_basename */ -PHPAPI void php_basename(char *s, size_t len, char *suffix, size_t sufflen, char **p_ret, int *p_len) +PHPAPI void php_basename(char *s, size_t len, char *suffix, size_t sufflen, char **p_ret, size_t *p_len) { - char *ret=NULL, *c; - c = s + len - 1; - - /* strip trailing slashes */ - while (*c == '/' + char *ret = NULL, *c, *comp, *cend; + size_t inc_len, cnt; + int state; + + c = comp = cend = s; + cnt = len; + state = 0; + while (cnt 0) { + inc_len = (*c == '\0' ? 1: php_mblen(c, cnt)); + + switch (inc_len) { + case -2: + case -1: +inc_len = 1; +php_mblen(NULL, 0); +break; + case 0: +goto quit_loop; + case 1: #ifdef PHP_WIN32 - || (*c == '\\' !IsDBCSLeadByte(*(c-1))) +if (*c == '/' || *c == '\\') { +#else +if (*c == '/') { #endif - ) { - c--; - len--; + if (state == 1) { + state = 0; + cend = c; + } +} else { + if (state == 0) { + comp = c; + state = 1; + } +} + default: +break; + } + c += inc_len; + cnt -= inc_len; } - /* do suffix removal as the unix
[PHP-CVS] cvs: php-src /ext/standard ftp_fopen_wrapper.c php_string.h string.c
moriyoshi Wed Dec 10 02:15:29 2003 EDT Modified files: /php-src/ext/standard ftp_fopen_wrapper.c php_string.h string.c Log: Fix bug #26574 (basename() doesn't work properly with multibyte characters) Index: php-src/ext/standard/ftp_fopen_wrapper.c diff -u php-src/ext/standard/ftp_fopen_wrapper.c:1.66 php-src/ext/standard/ftp_fopen_wrapper.c:1.67 --- php-src/ext/standard/ftp_fopen_wrapper.c:1.66 Sat Nov 29 15:01:00 2003 +++ php-src/ext/standard/ftp_fopen_wrapper.cWed Dec 10 02:15:28 2003 @@ -18,7 +18,7 @@ | Sara Golemon [EMAIL PROTECTED] | +--+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.66 2003/11/29 20:01:00 pollita Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.67 2003/12/10 07:15:28 moriyoshi Exp $ */ #include php.h #include php_globals.h @@ -562,7 +562,7 @@ php_stream *innerstream = (php_stream *)stream-abstract; size_t tmp_len; char *basename; - int basename_len; + size_t basename_len; if (count != sizeof(php_stream_dirent)) { return 0; @@ -586,8 +586,9 @@ return 0; } - memcpy(ent-d_name, basename, MIN((int)sizeof(ent-d_name), basename_len)-1); - ent-d_name[sizeof(ent-d_name)-1] = '\0'; + tmp_len = MIN(sizeof(ent-d_name), basename_len) - 1; + memcpy(ent-d_name, basename, tmp_len); + ent-d_name[tmp_len] = '\0'; efree(basename); return sizeof(php_stream_dirent); Index: php-src/ext/standard/php_string.h diff -u php-src/ext/standard/php_string.h:1.81 php-src/ext/standard/php_string.h:1.82 --- php-src/ext/standard/php_string.h:1.81 Wed Dec 10 01:08:39 2003 +++ php-src/ext/standard/php_string.h Wed Dec 10 02:15:28 2003 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: php_string.h,v 1.81 2003/12/10 06:08:39 moriyoshi Exp $ */ +/* $Id: php_string.h,v 1.82 2003/12/10 07:15:28 moriyoshi Exp $ */ /* Synced with php 3.0 revision 1.43 1999-06-16 [ssb] */ @@ -122,7 +122,7 @@ PHPAPI char *php_addcslashes(char *str, int length, int *new_length, int freeit, char *what, int wlength TSRMLS_DC); PHPAPI void php_stripslashes(char *str, int *len TSRMLS_DC); PHPAPI void php_stripcslashes(char *str, int *len); -PHPAPI void php_basename(char *str, size_t len , char *suffix, size_t sufflen, char **p_ret, int *p_len); +PHPAPI void php_basename(char *str, size_t len , char *suffix, size_t sufflen, char **p_ret, size_t *p_len); PHPAPI size_t php_dirname(char *str, size_t len); PHPAPI char *php_stristr(unsigned char *s, unsigned char *t, size_t s_len, size_t t_len); PHPAPI char *php_str_to_str_ex(char *haystack, int length, char *needle, Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.405 php-src/ext/standard/string.c:1.406 --- php-src/ext/standard/string.c:1.405 Wed Dec 10 01:04:15 2003 +++ php-src/ext/standard/string.c Wed Dec 10 02:15:28 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.405 2003/12/10 06:04:15 moriyoshi Exp $ */ +/* $Id: string.c,v 1.406 2003/12/10 07:15:28 moriyoshi Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -1068,56 +1068,69 @@ /* {{{ php_basename */ -PHPAPI void php_basename(char *s, size_t len, char *suffix, size_t sufflen, char **p_ret, int *p_len) +PHPAPI void php_basename(char *s, size_t len, char *suffix, size_t sufflen, char **p_ret, size_t *p_len) { - char *ret=NULL, *c; - c = s + len - 1; - - /* strip trailing slashes */ - while (*c == '/' + char *ret = NULL, *c, *comp, *cend; + size_t inc_len, cnt; + int state; + + c = comp = cend = s; + cnt = len; + state = 0; + while (cnt 0) { + inc_len = (*c == '\0' ? 1: php_mblen(c, cnt)); + + switch (inc_len) { + case -2: + case -1: + inc_len = 1; + php_mblen(NULL, 0); + break; + case 0: + goto quit_loop; + case 1: #ifdef PHP_WIN32 - || (*c == '\\' !IsDBCSLeadByte(*(c-1))) + if (*c == '/' || *c == '\\') { +#else + if (*c == '/') { #endif - ) { - c--; - len--; + if (state == 1) { + state = 0; + cend = c; + } + } else { + if (state == 0) { +
[PHP-CVS] cvs: php-src /ext/standard ftp_fopen_wrapper.c
pollita Sat Nov 29 12:16:59 2003 EDT Modified files: /php-src/ext/standard ftp_fopen_wrapper.c Log: Finish off ftp://'s url_stat support Index: php-src/ext/standard/ftp_fopen_wrapper.c diff -u php-src/ext/standard/ftp_fopen_wrapper.c:1.64 php-src/ext/standard/ftp_fopen_wrapper.c:1.65 --- php-src/ext/standard/ftp_fopen_wrapper.c:1.64 Fri Nov 28 18:25:26 2003 +++ php-src/ext/standard/ftp_fopen_wrapper.cSat Nov 29 12:16:58 2003 @@ -18,7 +18,7 @@ | Sara Golemon [EMAIL PROTECTED] | +--+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.64 2003/11/28 23:25:26 pollita Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.65 2003/11/29 17:16:58 pollita Exp $ */ #include php.h #include php_globals.h @@ -721,14 +721,23 @@ /* If ssb is NULL then someone is misbehaving */ if (!ssb) return -1; - memset(ssb, 0, sizeof(php_stream_statbuf)); - stream = php_ftp_fopen_connect(wrapper, url, r, 0, NULL, NULL, context, resource, NULL, NULL TSRMLS_CC); + stream = php_ftp_fopen_connect(wrapper, url, r, 0, NULL, context, NULL, resource, NULL, NULL TSRMLS_CC); if (!stream) { goto stat_errexit; } - /* Size is the only reliable attribute returned by FTP */ + ssb-sb.st_mode = 0644; /* FTP won't give us a valid mode, so aproximate one based on being readable */ + php_stream_write_string(stream, CWD );/* If we can CWD to it, it's a directory (maybe a link, but we can't tell) */ + php_stream_write_string(stream, resource-path); + php_stream_write_string(stream, \r\n); + result = GET_FTP_RESULT(stream); + if (result 200 || result 299) { + ssb-sb.st_mode |= S_IFREG; + } else { + ssb-sb.st_mode |= S_IFDIR; + } + php_stream_write_string(stream, SIZE ); if (resource-path != NULL) { php_stream_write_string(stream, resource-path); @@ -736,13 +745,30 @@ php_stream_write_string(stream, /); } php_stream_write_string(stream, \r\n); - result = GET_FTP_RESULT(stream); if (result 200 || result 299) { - goto stat_errexit; + /* Failure either means it doesn't exist + or it's a directory and this server + fails on listing directory sizes */ + if (ssb-sb.st_mode S_IFDIR) { + ssb-sb.st_size = 0; + } else { + goto stat_errexit; + } + } else { + ssb-sb.st_size = atoi(tmp_line + 4); } - sscanf(tmp_line + 4, %d, (int *)(ssb-sb.st_size)); + ssb-sb.st_ino = 0; /* Unknown values */ + ssb-sb.st_uid = 0; + ssb-sb.st_gid = 0; + ssb-sb.st_atime = -1; + ssb-sb.st_mtime = -1; + ssb-sb.st_ctime = -1; + ssb-sb.st_nlink = 1; + ssb-sb.st_rdev = -1; + ssb-sb.st_blksize = 4096; /* Guess since FTP won't expose this information */ + ssb-sb.st_blocks = ceil(ssb-sb.st_size / ssb-sb.st_blksize); php_stream_close(stream); php_url_free(resource); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard ftp_fopen_wrapper.c
pollita Sat Nov 29 15:01:02 2003 EDT Modified files: /php-src/ext/standard ftp_fopen_wrapper.c Log: Add in missing stat element and fix win32 build Index: php-src/ext/standard/ftp_fopen_wrapper.c diff -u php-src/ext/standard/ftp_fopen_wrapper.c:1.65 php-src/ext/standard/ftp_fopen_wrapper.c:1.66 --- php-src/ext/standard/ftp_fopen_wrapper.c:1.65 Sat Nov 29 12:16:58 2003 +++ php-src/ext/standard/ftp_fopen_wrapper.cSat Nov 29 15:01:00 2003 @@ -18,7 +18,7 @@ | Sara Golemon [EMAIL PROTECTED] | +--+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.65 2003/11/29 17:16:58 pollita Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.66 2003/11/29 20:01:00 pollita Exp $ */ #include php.h #include php_globals.h @@ -760,6 +760,7 @@ } ssb-sb.st_ino = 0; /* Unknown values */ + ssb-sb.st_dev = 0; ssb-sb.st_uid = 0; ssb-sb.st_gid = 0; ssb-sb.st_atime = -1; @@ -767,9 +768,12 @@ ssb-sb.st_ctime = -1; ssb-sb.st_nlink = 1; ssb-sb.st_rdev = -1; +#ifdef HAVE_ST_BLKSIZE ssb-sb.st_blksize = 4096; /* Guess since FTP won't expose this information */ - ssb-sb.st_blocks = ceil(ssb-sb.st_size / ssb-sb.st_blksize); - +#ifdef HAVE_ST_BLOCKS + ssb-sb.st_blocks = (int)((4095 + ssb-sb.st_size) / ssb-sb.st_blksize); /* emulate ceil */ +#endif +#endif php_stream_close(stream); php_url_free(resource); return 0; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard ftp_fopen_wrapper.c
pollita Mon Aug 25 18:25:33 2003 EDT Modified files: /php-src/ext/standard ftp_fopen_wrapper.c Log: Bugfix#25239 Closing control stream while data stream is open violates RFC959 section 2.3 Index: php-src/ext/standard/ftp_fopen_wrapper.c diff -u php-src/ext/standard/ftp_fopen_wrapper.c:1.60 php-src/ext/standard/ftp_fopen_wrapper.c:1.61 --- php-src/ext/standard/ftp_fopen_wrapper.c:1.60 Wed Aug 20 17:59:29 2003 +++ php-src/ext/standard/ftp_fopen_wrapper.cMon Aug 25 18:25:33 2003 @@ -18,7 +18,7 @@ | Sara Golemon [EMAIL PROTECTED] | +--+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.60 2003/08/20 21:59:29 pollita Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.61 2003/08/25 22:25:33 pollita Exp $ */ #include php.h #include php_globals.h @@ -521,13 +521,6 @@ goto errexit; } - /* close control connection if not in ssl mode */ - if (!use_ssl) { - php_stream_write_string(stream, QUIT\r\n); - php_stream_close(stream); - stream = NULL; - } - php_stream_context_set(datastream, context); php_stream_notify_progress_init(context, 0, file_size); @@ -685,13 +678,6 @@ goto opendir_errexit; } - /* close control connection if not in ssl mode */ - if (!use_ssl) { - php_stream_write_string(stream, QUIT\r\n); - php_stream_close(stream); - stream = NULL; - } - php_stream_context_set(datastream, context); if (use_ssl_on_data (php_stream_xport_crypto_setup(stream, -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard ftp_fopen_wrapper.c
pollita Fri Aug 8 02:18:25 2003 EDT Modified files: /php-src/ext/standard ftp_fopen_wrapper.c Log: Plug leak in ftp_url_stat Index: php-src/ext/standard/ftp_fopen_wrapper.c diff -u php-src/ext/standard/ftp_fopen_wrapper.c:1.58 php-src/ext/standard/ftp_fopen_wrapper.c:1.59 --- php-src/ext/standard/ftp_fopen_wrapper.c:1.58 Tue Jun 17 23:26:29 2003 +++ php-src/ext/standard/ftp_fopen_wrapper.cFri Aug 8 02:18:25 2003 @@ -18,7 +18,7 @@ | Sara Golemon [EMAIL PROTECTED] | +--+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.58 2003/06/18 03:26:29 pollita Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.59 2003/08/08 06:18:25 pollita Exp $ */ #include php.h #include php_globals.h @@ -745,6 +745,7 @@ sscanf(tmp_line + 4, %d, (int *)(ssb-sb.st_size)); php_stream_close(stream); + php_url_free(resource); return 0; stat_errexit: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php