[PHP-CVS] cvs: php-src /main fopen_wrappers.c /main/streams plain_wrapper.c
iliaa Tue Feb 10 16:14:35 2009 UTC Modified files: /php-src/main/streams plain_wrapper.c /php-src/main fopen_wrappers.c Log: MFB:Adjust condition http://cvs.php.net/viewvc.cgi/php-src/main/streams/plain_wrapper.c?r1=1.99&r2=1.100&diff_format=u Index: php-src/main/streams/plain_wrapper.c diff -u php-src/main/streams/plain_wrapper.c:1.99 php-src/main/streams/plain_wrapper.c:1.100 --- php-src/main/streams/plain_wrapper.c:1.99 Tue Feb 10 14:22:19 2009 +++ php-src/main/streams/plain_wrapper.cTue Feb 10 16:14:35 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: plain_wrapper.c,v 1.99 2009/02/10 14:22:19 iliaa Exp $ */ +/* $Id: plain_wrapper.c,v 1.100 2009/02/10 16:14:35 iliaa Exp $ */ #include "php.h" #include "php_globals.h" @@ -1289,7 +1289,7 @@ /* getcwd() will return always return [DRIVE_LETTER]:/) on windows. */ *(cwd+3) = '\0'; - if (snprintf(trypath, MAXPATHLEN, "%s%s", cwd, filename) > MAXPATHLEN) { + if (snprintf(trypath, MAXPATHLEN, "%s%s", cwd, filename) >= MAXPATHLEN) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%s/%s path was truncated to %d", cwd, filename, MAXPATHLEN); } @@ -1343,7 +1343,7 @@ if (*ptr == '\0') { goto stream_skip; } - if (snprintf(trypath, MAXPATHLEN, "%s/%s", ptr, filename) > MAXPATHLEN) { + if (snprintf(trypath, MAXPATHLEN, "%s/%s", ptr, filename) >= MAXPATHLEN) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%s/%s path was truncated to %d", ptr, filename, MAXPATHLEN); } http://cvs.php.net/viewvc.cgi/php-src/main/fopen_wrappers.c?r1=1.211&r2=1.212&diff_format=u Index: php-src/main/fopen_wrappers.c diff -u php-src/main/fopen_wrappers.c:1.211 php-src/main/fopen_wrappers.c:1.212 --- php-src/main/fopen_wrappers.c:1.211 Tue Feb 10 14:22:19 2009 +++ php-src/main/fopen_wrappers.c Tue Feb 10 16:14:35 2009 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: fopen_wrappers.c,v 1.211 2009/02/10 14:22:19 iliaa Exp $ */ +/* $Id: fopen_wrappers.c,v 1.212 2009/02/10 16:14:35 iliaa Exp $ */ /* {{{ includes */ @@ -636,7 +636,7 @@ *end = '\0'; end++; } - if (snprintf(trypath, MAXPATHLEN, "%s/%s", ptr, filename) > MAXPATHLEN) { + if (snprintf(trypath, MAXPATHLEN, "%s/%s", ptr, filename) >= MAXPATHLEN) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%s/%s path was truncated to %d", ptr, filename, MAXPATHLEN); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main fopen_wrappers.c /main/streams plain_wrapper.c
iliaa Tue Feb 10 14:22:19 2009 UTC Modified files: /php-src/main/streams plain_wrapper.c /php-src/main fopen_wrappers.c Log: MFB: Added path truncation E_NOTICE to let people now when path resolving caused the file path to be truncated. http://cvs.php.net/viewvc.cgi/php-src/main/streams/plain_wrapper.c?r1=1.98&r2=1.99&diff_format=u Index: php-src/main/streams/plain_wrapper.c diff -u php-src/main/streams/plain_wrapper.c:1.98 php-src/main/streams/plain_wrapper.c:1.99 --- php-src/main/streams/plain_wrapper.c:1.98 Wed Dec 31 11:12:39 2008 +++ php-src/main/streams/plain_wrapper.cTue Feb 10 14:22:19 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: plain_wrapper.c,v 1.98 2008/12/31 11:12:39 sebastian Exp $ */ +/* $Id: plain_wrapper.c,v 1.99 2009/02/10 14:22:19 iliaa Exp $ */ #include "php.h" #include "php_globals.h" @@ -1289,7 +1289,9 @@ /* getcwd() will return always return [DRIVE_LETTER]:/) on windows. */ *(cwd+3) = '\0'; - snprintf(trypath, MAXPATHLEN, "%s%s", cwd, filename); + if (snprintf(trypath, MAXPATHLEN, "%s%s", cwd, filename) > MAXPATHLEN) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%s/%s path was truncated to %d", cwd, filename, MAXPATHLEN); + } free(cwd); @@ -1341,7 +1343,9 @@ if (*ptr == '\0') { goto stream_skip; } - snprintf(trypath, MAXPATHLEN, "%s/%s", ptr, filename); + if (snprintf(trypath, MAXPATHLEN, "%s/%s", ptr, filename) > MAXPATHLEN) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%s/%s path was truncated to %d", ptr, filename, MAXPATHLEN); + } if (((options & STREAM_DISABLE_OPEN_BASEDIR) == 0) && php_check_open_basedir_ex(trypath, 0 TSRMLS_CC)) { goto stream_skip; http://cvs.php.net/viewvc.cgi/php-src/main/fopen_wrappers.c?r1=1.210&r2=1.211&diff_format=u Index: php-src/main/fopen_wrappers.c diff -u php-src/main/fopen_wrappers.c:1.210 php-src/main/fopen_wrappers.c:1.211 --- php-src/main/fopen_wrappers.c:1.210 Wed Dec 31 11:12:38 2008 +++ php-src/main/fopen_wrappers.c Tue Feb 10 14:22:19 2009 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: fopen_wrappers.c,v 1.210 2008/12/31 11:12:38 sebastian Exp $ */ +/* $Id: fopen_wrappers.c,v 1.211 2009/02/10 14:22:19 iliaa Exp $ */ /* {{{ includes */ @@ -636,7 +636,9 @@ *end = '\0'; end++; } - snprintf(trypath, MAXPATHLEN, "%s/%s", ptr, filename); + if (snprintf(trypath, MAXPATHLEN, "%s/%s", ptr, filename) > MAXPATHLEN) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%s/%s path was truncated to %d", ptr, filename, MAXPATHLEN); + } fp = php_fopen_and_set_opened_path(trypath, mode, opened_path TSRMLS_CC); if (fp) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main fopen_wrappers.c /main/streams plain_wrapper.c
dmitry Fri Nov 10 10:55:43 2006 UTC Modified files: /php-src/main fopen_wrappers.c /php-src/main/streams plain_wrapper.c Log: Removed unnecessary checks for ISREG file and corresponding stat() calls on Wind ows http://cvs.php.net/viewvc.cgi/php-src/main/fopen_wrappers.c?r1=1.185&r2=1.186&diff_format=u Index: php-src/main/fopen_wrappers.c diff -u php-src/main/fopen_wrappers.c:1.185 php-src/main/fopen_wrappers.c:1.186 --- php-src/main/fopen_wrappers.c:1.185 Fri Nov 10 09:56:37 2006 +++ php-src/main/fopen_wrappers.c Fri Nov 10 10:55:43 2006 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: fopen_wrappers.c,v 1.185 2006/11/10 09:56:37 dmitry Exp $ */ +/* $Id: fopen_wrappers.c,v 1.186 2006/11/10 10:55:43 dmitry Exp $ */ /* {{{ includes */ @@ -263,7 +263,9 @@ PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle TSRMLS_DC) { FILE *fp; +#ifndef PHP_WIN32 struct stat st; +#endif char *path_info, *filename; int length; @@ -329,11 +331,14 @@ } fp = VCWD_FOPEN(filename, "rb"); +#ifndef PHP_WIN32 /* refuse to open anything that is not a regular file */ if (fp && (0 > fstat(fileno(fp), &st) || !S_ISREG(st.st_mode))) { fclose(fp); fp = NULL; } +#endif + if (!fp) { STR_FREE(SG(request_info).path_translated); /* for same reason as above */ SG(request_info).path_translated = NULL; http://cvs.php.net/viewvc.cgi/php-src/main/streams/plain_wrapper.c?r1=1.74&r2=1.75&diff_format=u Index: php-src/main/streams/plain_wrapper.c diff -u php-src/main/streams/plain_wrapper.c:1.74 php-src/main/streams/plain_wrapper.c:1.75 --- php-src/main/streams/plain_wrapper.c:1.74 Thu Oct 19 09:49:56 2006 +++ php-src/main/streams/plain_wrapper.cFri Nov 10 10:55:43 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: plain_wrapper.c,v 1.74 2006/10/19 09:49:56 dmitry Exp $ */ +/* $Id: plain_wrapper.c,v 1.75 2006/11/10 10:55:43 dmitry Exp $ */ #include "php.h" #include "php_globals.h" @@ -891,6 +891,8 @@ efree(persistent_id); } + /* WIN32 always set ISREG flag */ +#ifndef PHP_WIN32 /* sanity checks for include/require. * We check these after opening the stream, so that we save * on fstat() syscalls */ @@ -899,15 +901,12 @@ int r; r = do_fstat(self, 0); - if ( -#ifndef PHP_WIN32 - (r != 0) || /* it is OK for fstat to fail under win32 */ -#endif - (r == 0 && !S_ISREG(self->sb.st_mode))) { + if ((r == 0 && !S_ISREG(self->sb.st_mode))) { php_stream_close(ret); return NULL; } } +#endif return ret; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php