[PHP-CVS] cvs: php-src /ext/standard dir.c /ext/standard/tests/file bug45181.phpt
lbarnaudMon Aug 11 22:38:17 2008 UTC Added files: /php-src/ext/standard/tests/filebug45181.phpt Modified files: /php-src/ext/standard dir.c Log: Fixed #45181 (chdir() should clear relative entries in stat cache) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dir.c?r1=1.178r2=1.179diff_format=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.178 php-src/ext/standard/dir.c:1.179 --- php-src/ext/standard/dir.c:1.178Thu Jul 24 12:48:47 2008 +++ php-src/ext/standard/dir.c Mon Aug 11 22:38:17 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.178 2008/07/24 12:48:47 felipe Exp $ */ +/* $Id: dir.c,v 1.179 2008/08/11 22:38:17 lbarnaud Exp $ */ /* {{{ includes/startup/misc */ @@ -26,6 +26,7 @@ #include php_dir.h #include php_string.h #include php_scandir.h +#include basic_functions.h #ifdef HAVE_DIRENT_H #include dirent.h @@ -354,6 +355,15 @@ RETURN_FALSE; } + if (BG(CurrentStatFile) !IS_ABSOLUTE_PATH(BG(CurrentStatFile), strlen(BG(CurrentStatFile { + efree(BG(CurrentStatFile)); + BG(CurrentStatFile) = NULL; + } + if (BG(CurrentLStatFile) !IS_ABSOLUTE_PATH(BG(CurrentLStatFile), strlen(BG(CurrentLStatFile { + efree(BG(CurrentLStatFile)); + BG(CurrentLStatFile) = NULL; + } + RETURN_TRUE; } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/bug45181.phpt?view=markuprev=1.1 Index: php-src/ext/standard/tests/file/bug45181.phpt +++ php-src/ext/standard/tests/file/bug45181.phpt --TEST-- Bug #45181 (chdir() should clear relative entries in stat cache) --FILE-- ?php mkdir(bug45181_x); var_dump(is_dir(bug45181_x)); chdir(bug45181_x); var_dump(is_dir(bug45181_x)); ? --CLEAN-- ?php rmdir(bug45181_x); ? --EXPECT-- bool(true) bool(false) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c /ext/standard/tests/file chroot_001.phpt
lbarnaudMon Aug 11 23:14:21 2008 UTC Added files: /php-src/ext/standard/tests/filechroot_001.phpt Modified files: /php-src/ext/standard dir.c Log: clear stat cache in chroot() http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dir.c?r1=1.179r2=1.180diff_format=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.179 php-src/ext/standard/dir.c:1.180 --- php-src/ext/standard/dir.c:1.179Mon Aug 11 22:38:17 2008 +++ php-src/ext/standard/dir.c Mon Aug 11 23:14:21 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.179 2008/08/11 22:38:17 lbarnaud Exp $ */ +/* $Id: dir.c,v 1.180 2008/08/11 23:14:21 lbarnaud Exp $ */ /* {{{ includes/startup/misc */ @@ -320,7 +320,7 @@ RETURN_FALSE; } - realpath_cache_clean(TSRMLS_C); + php_clear_stat_cache(1, NULL, 0 TSRMLS_CC); ret = chdir(/); http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/chroot_001.phpt?view=markuprev=1.1 Index: php-src/ext/standard/tests/file/chroot_001.phpt +++ php-src/ext/standard/tests/file/chroot_001.phpt --TEST-- chroot() --SKIPIF-- ?php chdir(/); if ([EMAIL PROTECTED](testtmpskipifdir)) { die(skip for root only); } rmdir(testtmpskipifdir); if (!function_exists(chroot)) { die(skip chroot() not available); } ? --FILE-- ?php mkdir(chroot_001_x); var_dump(is_dir(chroot_001_x)); var_dump(chroot(chroot_001_x)); var_dump(is_dir(chroot_001_x)); var_dump(realpath(.)); ? --CLEAN-- ?php rmdir(chroot_001_x); ? --EXPECTF-- bool(true) bool(true) bool(false) %unicode|string%(1) / -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c /ext/standard/tests/dir closedir_error.phpt closedir_variation1.phpt readdir_error.phpt readdir_variation1.phpt rewinddir_error.phpt rewinddir_variation1.ph
felipe Thu Jul 24 12:48:47 2008 UTC Modified files: /php-src/ext/standard dir.c /php-src/ext/standard/tests/dir closedir_error.phpt closedir_variation1.phpt readdir_error.phpt readdir_variation1.phpt rewinddir_error.phpt rewinddir_variation1.phpt Log: - New parameter parsing API http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dir.c?r1=1.177r2=1.178diff_format=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.177 php-src/ext/standard/dir.c:1.178 --- php-src/ext/standard/dir.c:1.177Wed Jul 23 11:24:34 2008 +++ php-src/ext/standard/dir.c Thu Jul 24 12:48:47 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.177 2008/07/23 11:24:34 tony2001 Exp $ */ +/* $Id: dir.c,v 1.178 2008/07/24 12:48:47 felipe Exp $ */ /* {{{ includes/startup/misc */ @@ -74,6 +74,9 @@ static zend_class_entry *dir_class_entry_ptr; #define FETCH_DIRP() \ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |r, id) == FAILURE) { \ + return; \ + } \ if (ZEND_NUM_ARGS() == 0) { \ myself = getThis(); \ if (myself) { \ @@ -85,10 +88,8 @@ } else { \ ZEND_FETCH_RESOURCE(dirp, php_stream *, 0, DIRG(default_dir), Directory, php_file_le_stream()); \ } \ - } else if ((ZEND_NUM_ARGS() != 1) || zend_get_parameters_ex(1, id) == FAILURE) { \ - WRONG_PARAM_COUNT; \ } else { \ - dirp = (php_stream *) zend_fetch_resource(id TSRMLS_CC, -1, Directory, NULL, 1, php_file_le_stream()); \ + dirp = (php_stream *) zend_fetch_resource(id TSRMLS_CC, -1, Directory, NULL, 1, php_file_le_stream()); \ if (!dirp) \ RETURN_FALSE; \ } @@ -278,7 +279,7 @@ Close directory connection identified by the dir_handle */ PHP_FUNCTION(closedir) { - zval **id, **tmp, *myself; + zval *id = NULL, **tmp, *myself; php_stream *dirp; int rsrc_id; @@ -386,7 +387,7 @@ Rewind dir_handle back to the start */ PHP_FUNCTION(rewinddir) { - zval **id, **tmp, *myself; + zval *id = NULL, **tmp, *myself; php_stream *dirp; FETCH_DIRP(); @@ -404,7 +405,7 @@ Read directory entry from dir_handle */ PHP_NAMED_FUNCTION(php_if_readdir) { - zval **id, **tmp, *myself; + zval *id = NULL, **tmp, *myself; php_stream *dirp; php_stream_dirent entry; http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/closedir_error.phpt?r1=1.3r2=1.4diff_format=u Index: php-src/ext/standard/tests/dir/closedir_error.phpt diff -u php-src/ext/standard/tests/dir/closedir_error.phpt:1.3 php-src/ext/standard/tests/dir/closedir_error.phpt:1.4 --- php-src/ext/standard/tests/dir/closedir_error.phpt:1.3 Mon May 26 23:48:29 2008 +++ php-src/ext/standard/tests/dir/closedir_error.phpt Thu Jul 24 12:48:47 2008 @@ -40,6 +40,6 @@ -- Testing closedir() function with more than expected no. of arguments -- -Warning: Wrong parameter count for closedir() in %s on line %d +Warning: closedir() expects at most 1 parameter, 2 given in %s on line %d NULL ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/closedir_variation1.phpt?r1=1.3r2=1.4diff_format=u Index: php-src/ext/standard/tests/dir/closedir_variation1.phpt diff -u php-src/ext/standard/tests/dir/closedir_variation1.phpt:1.3 php-src/ext/standard/tests/dir/closedir_variation1.phpt:1.4 --- php-src/ext/standard/tests/dir/closedir_variation1.phpt:1.3 Mon May 26 23:48:29 2008 +++ php-src/ext/standard/tests/dir/closedir_variation1.phpt Thu Jul 24 12:48:47 2008 @@ -92,121 +92,121 @@ -- Iteration 1 -- -Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: closedir() expects parameter 1 to be resource, integer given in %s on line %d +NULL -- Iteration 2 -- -Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: closedir() expects parameter 1 to be resource, integer given in %s on line %d +NULL -- Iteration 3 -- -Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: closedir() expects parameter 1 to be resource, integer given in %s on line %d +NULL -- Iteration 4 -- -Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d -bool(false) +Warning: closedir() expects parameter 1 to be resource, integer given in %s on line %d +NULL -- Iteration 5 -- -Warning: closedir(): supplied argument is not a valid Directory
[PHP-CVS] cvs: php-src /ext/standard dir.c
tony2001Wed Mar 5 09:28:41 2008 UTC Modified files: /php-src/ext/standard dir.c Log: fix memory corruption due to double destruction of default dir handle (detected by ext/standard/tests/dir/readdir_variation6.phpt) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dir.c?r1=1.173r2=1.174diff_format=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.173 php-src/ext/standard/dir.c:1.174 --- php-src/ext/standard/dir.c:1.173Thu Feb 28 14:16:14 2008 +++ php-src/ext/standard/dir.c Wed Mar 5 09:28:41 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.173 2008/02/28 14:16:14 felipe Exp $ */ +/* $Id: dir.c,v 1.174 2008/03/05 09:28:41 tony2001 Exp $ */ /* {{{ includes/startup/misc */ @@ -283,9 +283,9 @@ if (dirp-rsrc_id == DIRG(default_dir)) { php_set_default_dir(-1 TSRMLS_CC); + } else { + zend_list_delete(dirp-rsrc_id); } - - zend_list_delete(dirp-rsrc_id); } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c
tony2001Wed Mar 5 12:09:34 2008 UTC Modified files: /php-src/ext/standard dir.c Log: apply better fix, so that the default handle would be closed when closing its reference http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dir.c?r1=1.174r2=1.175diff_format=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.174 php-src/ext/standard/dir.c:1.175 --- php-src/ext/standard/dir.c:1.174Wed Mar 5 09:28:41 2008 +++ php-src/ext/standard/dir.c Wed Mar 5 12:09:33 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.174 2008/03/05 09:28:41 tony2001 Exp $ */ +/* $Id: dir.c,v 1.175 2008/03/05 12:09:33 tony2001 Exp $ */ /* {{{ includes/startup/misc */ @@ -278,13 +278,15 @@ { zval **id, **tmp, *myself; php_stream *dirp; + int rsrc_id; FETCH_DIRP(); - if (dirp-rsrc_id == DIRG(default_dir)) { + rsrc_id = dirp-rsrc_id; + zend_list_delete(dirp-rsrc_id); + + if (rsrc_id == DIRG(default_dir)) { php_set_default_dir(-1 TSRMLS_CC); - } else { - zend_list_delete(dirp-rsrc_id); } } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-CVS] cvs: php-src /ext/standard dir.c
It seems you've broken ext/standard/tests/file/bug41655_1.phpt Thanks. Dmitry. -Original Message- From: Ilia Alshanetsky [mailto:[EMAIL PROTECTED] Sent: Thursday, September 20, 2007 2:40 AM To: php-cvs@lists.php.net Subject: [PHP-CVS] cvs: php-src /ext/standard dir.c iliaa Wed Sep 19 22:40:02 2007 UTC Modified files: /php-src/ext/standard dir.c Log: MFB: Fixed regression in glob() when enforcing safe_mode/open_basedir checks on paths containing '*' http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dir.c?r1=1. 169r2=1.170diff_format=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.169 php-src/ext/standard/dir.c:1.170 --- php-src/ext/standard/dir.c:1.169 Wed Sep 5 12:55:36 2007 +++ php-src/ext/standard/dir.cWed Sep 19 22:40:02 2007 @@ -16,7 +16,7 @@ +- -+ */ -/* $Id: dir.c,v 1.169 2007/09/05 12:55:36 iliaa Exp $ */ +/* $Id: dir.c,v 1.170 2007/09/19 22:40:02 iliaa Exp $ */ /* {{{ includes/startup/misc */ @@ -421,6 +421,7 @@ glob_t globbuf; unsigned int n; int ret; + zend_bool basedir_limit = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, Z|l, pppattern, flags) == FAILURE || php_stream_path_param_encode(pppattern, pattern, pattern_len, REPORT_ERRORS, FG(default_context)) == FAILURE) { @@ -455,18 +456,6 @@ } #endif - if (PG(open_basedir) *PG(open_basedir)) { - int pattern_len = strlen(pattern); - char *basename = estrndup(pattern, pattern_len); - - php_dirname(basename, pattern_len); - if (php_check_open_basedir(basename TSRMLS_CC)) { - efree(basename); - RETURN_FALSE; - } - efree(basename); - } - memset(globbuf, 0, sizeof(glob_t)); globbuf.gl_offs = 0; if (0 != (ret = glob(pattern, flags GLOB_FLAGMASK, NULL, globbuf))) { @@ -480,8 +469,7 @@ can be used for simple glob() calls without further error checking. */ - array_init(return_value); - return; + goto no_results; } #endif RETURN_FALSE; @@ -489,12 +477,26 @@ /* now catch the FreeBSD style of no matches */ if (!globbuf.gl_pathc || !globbuf.gl_pathv) { +no_results: + if (PG(open_basedir) *PG(open_basedir)) { + struct stat s; + + if (0 != VCWD_STAT(pattern, s) || S_IFDIR != (s.st_mode S_IFMT)) { + RETURN_FALSE; + } + } array_init(return_value); return; } array_init(return_value); for (n = 0; n globbuf.gl_pathc; n++) { + if (PG(open_basedir) *PG(open_basedir)) { + if (php_check_open_basedir_ex(globbuf.gl_pathv[n], 0 TSRMLS_CC)) { + basedir_limit = 1; + continue; + } + } /* we need to do this everytime since GLOB_ONLYDIR does not guarantee that * all directories will be filtered. GNU libc documentation states the * following: @@ -531,6 +533,11 @@ } globfree(globbuf); + + if (basedir_limit !zend_hash_num_elements(Z_ARRVAL_P(return_value))) { + zval_dtor(return_value); + RETURN_FALSE; + } } /* }}} */ #endif -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard dir.c
On 9/20/07, Dmitry Stogov [EMAIL PROTECTED] wrote: It seems you've broken ext/standard/tests/file/bug41655_1.phpt The test has to be updated. The last fix seems to be the only way to actually fix what was reported in #41655 (one can test if a file exists outside open_basedir using glob) and to do not break old applications: having glob returning false (error). We can introduce again the warning but it may defeat again the main purpose of this fix. Cheers, --Pierre -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c
iliaa Wed Sep 19 22:40:02 2007 UTC Modified files: /php-src/ext/standard dir.c Log: MFB: Fixed regression in glob() when enforcing safe_mode/open_basedir checks on paths containing '*' http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dir.c?r1=1.169r2=1.170diff_format=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.169 php-src/ext/standard/dir.c:1.170 --- php-src/ext/standard/dir.c:1.169Wed Sep 5 12:55:36 2007 +++ php-src/ext/standard/dir.c Wed Sep 19 22:40:02 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.169 2007/09/05 12:55:36 iliaa Exp $ */ +/* $Id: dir.c,v 1.170 2007/09/19 22:40:02 iliaa Exp $ */ /* {{{ includes/startup/misc */ @@ -421,6 +421,7 @@ glob_t globbuf; unsigned int n; int ret; + zend_bool basedir_limit = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, Z|l, pppattern, flags) == FAILURE || php_stream_path_param_encode(pppattern, pattern, pattern_len, REPORT_ERRORS, FG(default_context)) == FAILURE) { @@ -455,18 +456,6 @@ } #endif - if (PG(open_basedir) *PG(open_basedir)) { - int pattern_len = strlen(pattern); - char *basename = estrndup(pattern, pattern_len); - - php_dirname(basename, pattern_len); - if (php_check_open_basedir(basename TSRMLS_CC)) { - efree(basename); - RETURN_FALSE; - } - efree(basename); - } - memset(globbuf, 0, sizeof(glob_t)); globbuf.gl_offs = 0; if (0 != (ret = glob(pattern, flags GLOB_FLAGMASK, NULL, globbuf))) { @@ -480,8 +469,7 @@ can be used for simple glob() calls without further error checking. */ - array_init(return_value); - return; + goto no_results; } #endif RETURN_FALSE; @@ -489,12 +477,26 @@ /* now catch the FreeBSD style of no matches */ if (!globbuf.gl_pathc || !globbuf.gl_pathv) { +no_results: + if (PG(open_basedir) *PG(open_basedir)) { + struct stat s; + + if (0 != VCWD_STAT(pattern, s) || S_IFDIR != (s.st_mode S_IFMT)) { + RETURN_FALSE; + } + } array_init(return_value); return; } array_init(return_value); for (n = 0; n globbuf.gl_pathc; n++) { + if (PG(open_basedir) *PG(open_basedir)) { + if (php_check_open_basedir_ex(globbuf.gl_pathv[n], 0 TSRMLS_CC)) { + basedir_limit = 1; + continue; + } + } /* we need to do this everytime since GLOB_ONLYDIR does not guarantee that * all directories will be filtered. GNU libc documentation states the * following: @@ -531,6 +533,11 @@ } globfree(globbuf); + + if (basedir_limit !zend_hash_num_elements(Z_ARRVAL_P(return_value))) { + zval_dtor(return_value); + RETURN_FALSE; + } } /* }}} */ #endif -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c file.c
iliaa Wed Sep 5 12:55:37 2007 UTC Modified files: /php-src/ext/standard dir.c file.c Log: MFB: Fixed possible buffer overflows inside the fnmatch() and glob() functions http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dir.c?r1=1.168r2=1.169diff_format=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.168 php-src/ext/standard/dir.c:1.169 --- php-src/ext/standard/dir.c:1.168Wed Aug 22 14:58:30 2007 +++ php-src/ext/standard/dir.c Wed Sep 5 12:55:36 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.168 2007/08/22 14:58:30 jani Exp $ */ +/* $Id: dir.c,v 1.169 2007/09/05 12:55:36 iliaa Exp $ */ /* {{{ includes/startup/misc */ @@ -427,6 +427,11 @@ return; } + if (pattern_len = MAXPATHLEN) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Pattern exceeds the maximum allowed length of %d characters, MAXPATHLEN); + RETURN_FALSE; + } + if ((GLOB_AVAILABLE_FLAGS flags) != flags) { php_error_docref(NULL TSRMLS_CC, E_WARNING, At least one of the passed flags is invalid or not supported on this platform); RETURN_FALSE; http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.499r2=1.500diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.499 php-src/ext/standard/file.c:1.500 --- php-src/ext/standard/file.c:1.499 Mon Sep 3 11:53:43 2007 +++ php-src/ext/standard/file.c Wed Sep 5 12:55:36 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.499 2007/09/03 11:53:43 jani Exp $ */ +/* $Id: file.c,v 1.500 2007/09/05 12:55:36 iliaa Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -2894,6 +2894,11 @@ zend_unicode_to_string_ex(UG(utf8_conv), filename_utf8, filename_utf8_len, filename.u, filename_len, status); pattern.s = pattern_utf8; filename.s = filename_utf8; + filename_len = filename_utf8_len; + } + if (filename_len = MAXPATHLEN) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Filename exceeds the maximum allowed length of %d characters, MAXPATHLEN); + RETURN_FALSE; } RETVAL_BOOL( ! fnmatch( pattern.s, filename.s, flags )); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c
janiWed Aug 22 14:58:30 2007 UTC Modified files: /php-src/ext/standard dir.c Log: - Fixed bug #42365 (glob() crashes with invalid flags) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dir.c?r1=1.167r2=1.168diff_format=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.167 php-src/ext/standard/dir.c:1.168 --- php-src/ext/standard/dir.c:1.167Mon Jul 16 20:29:37 2007 +++ php-src/ext/standard/dir.c Wed Aug 22 14:58:30 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.167 2007/07/16 20:29:37 tony2001 Exp $ */ +/* $Id: dir.c,v 1.168 2007/08/22 14:58:30 jani Exp $ */ /* {{{ includes/startup/misc */ @@ -141,34 +141,56 @@ REGISTER_STRING_CONSTANT(PATH_SEPARATOR, pathsep_str, CONST_CS|CONST_PERSISTENT); #ifdef HAVE_GLOB + #ifdef GLOB_BRACE REGISTER_LONG_CONSTANT(GLOB_BRACE, GLOB_BRACE, CONST_CS | CONST_PERSISTENT); +#else +# define GLOB_BRACE 0 #endif + #ifdef GLOB_MARK REGISTER_LONG_CONSTANT(GLOB_MARK, GLOB_MARK, CONST_CS | CONST_PERSISTENT); +#else +# define GLOB_MARK 0 #endif + #ifdef GLOB_NOSORT REGISTER_LONG_CONSTANT(GLOB_NOSORT, GLOB_NOSORT, CONST_CS | CONST_PERSISTENT); +#else +# define GLOB_NOSORT 0 #endif + #ifdef GLOB_NOCHECK REGISTER_LONG_CONSTANT(GLOB_NOCHECK, GLOB_NOCHECK, CONST_CS | CONST_PERSISTENT); +#else +# define GLOB_NOCHECK 0 #endif + #ifdef GLOB_NOESCAPE REGISTER_LONG_CONSTANT(GLOB_NOESCAPE, GLOB_NOESCAPE, CONST_CS | CONST_PERSISTENT); +#else +# define GLOB_NOESCAPE 0 #endif + #ifdef GLOB_ERR REGISTER_LONG_CONSTANT(GLOB_ERR, GLOB_ERR, CONST_CS | CONST_PERSISTENT); +#else +# define GLOB_ERR 0 #endif #ifndef GLOB_ONLYDIR -#define GLOB_ONLYDIR (130) -#define GLOB_EMULATE_ONLYDIR -#define GLOB_FLAGMASK (~GLOB_ONLYDIR) +# define GLOB_ONLYDIR (130) +# define GLOB_EMULATE_ONLYDIR +# define GLOB_FLAGMASK (~GLOB_ONLYDIR) #else -#define GLOB_FLAGMASK (~0) +# define GLOB_FLAGMASK (~0) #endif +/* This is used for checking validity of passed flags (passing invalid flags causes segfault in glob()!! */ +#define GLOB_AVAILABLE_FLAGS (0 | GLOB_BRACE | GLOB_MARK | GLOB_NOSORT | GLOB_NOCHECK | GLOB_NOESCAPE | GLOB_ERR | GLOB_ONLYDIR) + REGISTER_LONG_CONSTANT(GLOB_ONLYDIR, GLOB_ONLYDIR, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(GLOB_AVAILABLE_FLAGS, GLOB_AVAILABLE_FLAGS, CONST_CS | CONST_PERSISTENT); #endif /* HAVE_GLOB */ @@ -405,6 +427,11 @@ return; } + if ((GLOB_AVAILABLE_FLAGS flags) != flags) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, At least one of the passed flags is invalid or not supported on this platform); + RETURN_FALSE; + } + #ifdef ZTS if (!IS_ABSOLUTE_PATH(pattern, pattern_len)) { result = VCWD_GETCWD(cwd, MAXPATHLEN); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c
tony2001Mon Jul 16 20:29:37 2007 UTC Modified files: /php-src/ext/standard dir.c Log: MFB: initialize glob struct http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dir.c?r1=1.166r2=1.167diff_format=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.166 php-src/ext/standard/dir.c:1.167 --- php-src/ext/standard/dir.c:1.166Tue Jun 26 12:14:24 2007 +++ php-src/ext/standard/dir.c Mon Jul 16 20:29:37 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.166 2007/06/26 12:14:24 tony2001 Exp $ */ +/* $Id: dir.c,v 1.167 2007/07/16 20:29:37 tony2001 Exp $ */ /* {{{ includes/startup/misc */ @@ -435,6 +435,7 @@ efree(basename); } + memset(globbuf, 0, sizeof(glob_t)); globbuf.gl_offs = 0; if (0 != (ret = glob(pattern, flags GLOB_FLAGMASK, NULL, globbuf))) { #ifdef GLOB_NOMATCH -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c
tony2001Tue Jun 26 12:14:24 2007 UTC Modified files: /php-src/ext/standard dir.c Log: add missing include and fix warning http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dir.c?r1=1.165r2=1.166diff_format=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.165 php-src/ext/standard/dir.c:1.166 --- php-src/ext/standard/dir.c:1.165Mon Jun 25 09:42:49 2007 +++ php-src/ext/standard/dir.c Tue Jun 26 12:14:24 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.165 2007/06/25 09:42:49 dmitry Exp $ */ +/* $Id: dir.c,v 1.166 2007/06/26 12:14:24 tony2001 Exp $ */ /* {{{ includes/startup/misc */ @@ -24,6 +24,7 @@ #include fopen_wrappers.h #include file.h #include php_dir.h +#include php_string.h #include php_scandir.h #ifdef HAVE_DIRENT_H -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard dir.c /ext/standard/tests/file bug41655_1.phpt
Hi Dmitry, On 6/25/07, Dmitry Stogov [EMAIL PROTECTED] wrote: dmitry Mon Jun 25 08:40:37 2007 UTC Modified files: /php-src/ext/standard dir.c /php-src/ext/standard/tests/filebug41655_1.phpt Log: Better fix for bug #41655 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dir.c?r1=1.163r2=1.164diff_format=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.163 php-src/ext/standard/dir.c:1.164 --- php-src/ext/standard/dir.c:1.163Tue Jun 12 13:42:04 2007 +++ php-src/ext/standard/dir.c Mon Jun 25 08:40:36 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.163 2007/06/12 13:42:04 scottmac Exp $ */ +/* $Id: dir.c,v 1.164 2007/06/25 08:40:36 dmitry Exp $ */ /* {{{ includes/startup/misc */ @@ -423,16 +423,15 @@ #endif if (PG(open_basedir) *PG(open_basedir)) { - size_t base_len = php_dirname(pattern, strlen(pattern)); - char pos = pattern[base_len]; - - pattern[base_len] = '\0'; - + int pattern_len = strlen(pattern); + char *basename = estrndup(pattern, pattern_len); + + php_dirname(basename, pattern_len); Why is it a better fix? In these versions (head and 5.2), we don't need to duplicate the pattern. I applied in 4.4 as dirname modifies the pattern. Cheers, --Pierre -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c /ext/standard/tests/file bug41655_1.phpt
dmitry Mon Jun 25 08:40:37 2007 UTC Modified files: /php-src/ext/standard dir.c /php-src/ext/standard/tests/filebug41655_1.phpt Log: Better fix for bug #41655 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dir.c?r1=1.163r2=1.164diff_format=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.163 php-src/ext/standard/dir.c:1.164 --- php-src/ext/standard/dir.c:1.163Tue Jun 12 13:42:04 2007 +++ php-src/ext/standard/dir.c Mon Jun 25 08:40:36 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.163 2007/06/12 13:42:04 scottmac Exp $ */ +/* $Id: dir.c,v 1.164 2007/06/25 08:40:36 dmitry Exp $ */ /* {{{ includes/startup/misc */ @@ -423,16 +423,15 @@ #endif if (PG(open_basedir) *PG(open_basedir)) { - size_t base_len = php_dirname(pattern, strlen(pattern)); - char pos = pattern[base_len]; - - pattern[base_len] = '\0'; - + int pattern_len = strlen(pattern); + char *basename = estrndup(pattern, pattern_len); + + php_dirname(basename, pattern_len); if (php_check_open_basedir(pattern TSRMLS_CC)) { + efree(basename); RETURN_FALSE; } - - pattern[base_len] = pos; + efree(basename); } globbuf.gl_offs = 0; http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/bug41655_1.phpt?r1=1.2r2=1.3diff_format=u Index: php-src/ext/standard/tests/file/bug41655_1.phpt diff -u php-src/ext/standard/tests/file/bug41655_1.phpt:1.2 php-src/ext/standard/tests/file/bug41655_1.phpt:1.3 --- php-src/ext/standard/tests/file/bug41655_1.phpt:1.2 Fri Jun 22 12:36:55 2007 +++ php-src/ext/standard/tests/file/bug41655_1.phpt Mon Jun 25 08:40:36 2007 @@ -7,4 +7,4 @@ $a=glob(./*.jpeg); ? --EXPECTF-- -Warning: glob() [%s]: open_basedir restriction in effect. File(.) is not within the allowed path(s): (/tmp) in %s on line %d +Warning: glob(): open_basedir restriction in effect. File(.) is not within the allowed path(s): (/tmp) in %s on line %d -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c
dmitry Mon Jun 25 09:42:49 2007 UTC Modified files: /php-src/ext/standard dir.c Log: (forgotten part of fix) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dir.c?r1=1.164r2=1.165diff_format=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.164 php-src/ext/standard/dir.c:1.165 --- php-src/ext/standard/dir.c:1.164Mon Jun 25 08:40:36 2007 +++ php-src/ext/standard/dir.c Mon Jun 25 09:42:49 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.164 2007/06/25 08:40:36 dmitry Exp $ */ +/* $Id: dir.c,v 1.165 2007/06/25 09:42:49 dmitry Exp $ */ /* {{{ includes/startup/misc */ @@ -427,7 +427,7 @@ char *basename = estrndup(pattern, pattern_len); php_dirname(basename, pattern_len); - if (php_check_open_basedir(pattern TSRMLS_CC)) { + if (php_check_open_basedir(basename TSRMLS_CC)) { efree(basename); RETURN_FALSE; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-CVS] cvs: php-src /ext/standard dir.c /ext/standard/tests/file bug41655_1.phpt
/php-src/ext/standard/tests/file/bug41655_2.phpt was broken because pattern was truncated by php_dirname(). Dmitry. -Original Message- From: Pierre [mailto:[EMAIL PROTECTED] Sent: Monday, June 25, 2007 12:52 PM To: Dmitry Stogov Cc: php-cvs@lists.php.net Subject: Re: [PHP-CVS] cvs: php-src /ext/standard dir.c /ext/standard/tests/file bug41655_1.phpt Hi Dmitry, On 6/25/07, Dmitry Stogov [EMAIL PROTECTED] wrote: dmitry Mon Jun 25 08:40:37 2007 UTC Modified files: /php-src/ext/standard dir.c /php-src/ext/standard/tests/filebug41655_1.phpt Log: Better fix for bug #41655 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dir.c?r1=1.163r2=1 .164diff_format=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.163 php-src/ext/standard/dir.c:1.164 --- php-src/ext/standard/dir.c:1.163Tue Jun 12 13:42:04 2007 +++ php-src/ext/standard/dir.c Mon Jun 25 08:40:36 2007 @@ -16,7 +16,7 @@ +- -+ */ -/* $Id: dir.c,v 1.163 2007/06/12 13:42:04 scottmac Exp $ */ +/* $Id: dir.c,v 1.164 2007/06/25 08:40:36 dmitry Exp $ */ /* {{{ includes/startup/misc */ @@ -423,16 +423,15 @@ #endif if (PG(open_basedir) *PG(open_basedir)) { - size_t base_len = php_dirname(pattern, strlen(pattern)); - char pos = pattern[base_len]; - - pattern[base_len] = '\0'; - + int pattern_len = strlen(pattern); + char *basename = estrndup(pattern, pattern_len); + + php_dirname(basename, pattern_len); Why is it a better fix? In these versions (head and 5.2), we don't need to duplicate the pattern. I applied in 4.4 as dirname modifies the pattern. Cheers, --Pierre -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c
iliaa Tue Jun 12 12:57:43 2007 UTC Modified files: /php-src/ext/standard dir.c Log: MFB: Fixed bug #41655 (open_basedir bypass via glob()) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dir.c?r1=1.161r2=1.162diff_format=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.161 php-src/ext/standard/dir.c:1.162 --- php-src/ext/standard/dir.c:1.161Tue May 29 20:11:23 2007 +++ php-src/ext/standard/dir.c Tue Jun 12 12:57:43 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.161 2007/05/29 20:11:23 iliaa Exp $ */ +/* $Id: dir.c,v 1.162 2007/06/12 12:57:43 iliaa Exp $ */ /* {{{ includes/startup/misc */ @@ -385,7 +385,6 @@ Find pathnames matching a pattern */ PHP_FUNCTION(glob) { - char cwd[MAXPATHLEN]; int cwd_skip = 0; #ifdef ZTS char work_pattern[MAXPATHLEN]; @@ -422,6 +421,19 @@ } #endif + if (PG(open_basedir) *PG(open_basedir)) { + size_t base_len = php_dirname(pattern, strlen(pattern)); + char pos = pattern[base_len]; + + pattern[base_len] = '\0'; + + if (php_check_open_basedir(pattern TSRMLS_CC)) { + RETURN_FALSE; + } + + pattern[base_len] = pos; + } + globbuf.gl_offs = 0; if (0 != (ret = glob(pattern, flags GLOB_FLAGMASK, NULL, globbuf))) { #ifdef GLOB_NOMATCH @@ -447,14 +459,6 @@ return; } - /* we assume that any glob pattern will match files from one directory only - so checking the dirname of the first match should be sufficient */ - strlcpy(cwd, globbuf.gl_pathv[0], MAXPATHLEN); - - if (php_check_open_basedir(cwd TSRMLS_CC)) { - RETURN_FALSE; - } - array_init(return_value); for (n = 0; n globbuf.gl_pathc; n++) { /* we need to do this everytime since GLOB_ONLYDIR does not guarantee that -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c
scottmacTue Jun 12 13:42:05 2007 UTC Modified files: /php-src/ext/standard dir.c Log: Fix ZTS build http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dir.c?r1=1.162r2=1.163diff_format=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.162 php-src/ext/standard/dir.c:1.163 --- php-src/ext/standard/dir.c:1.162Tue Jun 12 12:57:43 2007 +++ php-src/ext/standard/dir.c Tue Jun 12 13:42:04 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.162 2007/06/12 12:57:43 iliaa Exp $ */ +/* $Id: dir.c,v 1.163 2007/06/12 13:42:04 scottmac Exp $ */ /* {{{ includes/startup/misc */ @@ -387,6 +387,7 @@ { int cwd_skip = 0; #ifdef ZTS + char cwd[MAXPATHLEN]; char work_pattern[MAXPATHLEN]; char *result; #endif -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c mail.c user_filters.c /ext/standard/tests/array bug40709.phpt /ext/standard/tests/strings bug40432.phpt bug40704.phpt bug40754.phpt htmlentities18.phpt /e
iliaa Tue May 29 20:11:23 2007 UTC Modified files: /php-src/ext/standard user_filters.c mail.c dir.c /php-src/ext/standard/tests/array bug40709.phpt /php-src/ext/standard/tests/strings bug40432.phpt bug40704.phpt bug40754.phpt htmlentities18.phpt /php-src/ext/wddx/tests bug41283.phpt Log: MFB http://cvs.php.net/viewvc.cgi/php-src/ext/standard/user_filters.c?r1=1.45r2=1.46diff_format=u Index: php-src/ext/standard/user_filters.c diff -u php-src/ext/standard/user_filters.c:1.45 php-src/ext/standard/user_filters.c:1.46 --- php-src/ext/standard/user_filters.c:1.45Thu Feb 1 14:20:53 2007 +++ php-src/ext/standard/user_filters.c Tue May 29 20:11:23 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: user_filters.c,v 1.45 2007/02/01 14:20:53 tony2001 Exp $ */ +/* $Id: user_filters.c,v 1.46 2007/05/29 20:11:23 iliaa Exp $ */ #include php.h #include php_globals.h @@ -260,6 +260,7 @@ zval *obj, *zfilter; zval func_name; zval *retval = NULL; + int len; /* some sanity checks */ if (persistent) { @@ -268,9 +269,10 @@ return NULL; } + len = strlen(filtername); + /* determine the classname/class entry */ - if (FAILURE == zend_hash_find(BG(user_filter_map), (char*)filtername, - strlen(filtername) + 1, (void**)fdat)) { + if (FAILURE == zend_hash_find(BG(user_filter_map), (char*)filtername, len + 1, (void**)fdat)) { char *period; /* Userspace Filters using ambiguous wildcards could cause problems. @@ -279,10 +281,10 @@ TODO: Allow failed userfilter creations to continue scanning through the list */ if ((period = strrchr(filtername, '.'))) { - char *wildcard; + char *wildcard = emalloc(len + 3); /* Search for wildcard matches instead */ - wildcard = estrdup(filtername); + memcpy(wildname, filtername, len + 1); /* copy \0 */ period = wildcard + (period - filtername); while (period) { *period = '\0'; http://cvs.php.net/viewvc.cgi/php-src/ext/standard/mail.c?r1=1.91r2=1.92diff_format=u Index: php-src/ext/standard/mail.c diff -u php-src/ext/standard/mail.c:1.91 php-src/ext/standard/mail.c:1.92 --- php-src/ext/standard/mail.c:1.91Mon Jan 1 09:29:32 2007 +++ php-src/ext/standard/mail.c Tue May 29 20:11:23 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: mail.c,v 1.91 2007/01/01 09:29:32 sebastian Exp $ */ +/* $Id: mail.c,v 1.92 2007/05/29 20:11:23 iliaa Exp $ */ #include stdlib.h #include ctype.h @@ -47,8 +47,8 @@ #define SKIP_LONG_HEADER_SEP(str, pos) \ if (str[pos] == '\r' str[pos + 1] == '\n' (str[pos + 2] == ' ' || str[pos + 2] == '\t')) {\ - pos += 3; \ - while (str[pos] == ' ' || str[pos] == '\t') { \ + pos += 2; \ + while (str[pos + 1] == ' ' || str[pos + 1] == '\t') { \ pos++; \ } \ continue; \ http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dir.c?r1=1.160r2=1.161diff_format=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.160 php-src/ext/standard/dir.c:1.161 --- php-src/ext/standard/dir.c:1.160Mon Jan 22 09:32:55 2007 +++ php-src/ext/standard/dir.c Tue May 29 20:11:23 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.160 2007/01/22 09:32:55 dmitry Exp $ */ +/* $Id: dir.c,v 1.161 2007/05/29 20:11:23 iliaa Exp $ */ /* {{{ includes/startup/misc */ @@ -449,7 +449,7 @@ /* we assume that any glob pattern will match files from one directory only so checking the dirname of the first match should be sufficient */ - strncpy(cwd, globbuf.gl_pathv[0], MAXPATHLEN); + strlcpy(cwd, globbuf.gl_pathv[0], MAXPATHLEN); if
[PHP-CVS] cvs: php-src /ext/standard dir.c
iliaa Wed Oct 4 23:20:54 2006 UTC Modified files: /php-src/ext/standard dir.c Log: MFB: Fixed missing open_basedir check inside chdir() function. http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dir.c?r1=1.157r2=1.158diff_format=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.157 php-src/ext/standard/dir.c:1.158 --- php-src/ext/standard/dir.c:1.157Mon Oct 2 18:14:42 2006 +++ php-src/ext/standard/dir.c Wed Oct 4 23:20:54 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.157 2006/10/02 18:14:42 pollita Exp $ */ +/* $Id: dir.c,v 1.158 2006/10/04 23:20:54 iliaa Exp $ */ /* {{{ includes/startup/misc */ @@ -310,7 +310,9 @@ php_stream_path_param_encode(ppstr, str, str_len, REPORT_ERRORS, FG(default_context)) == FAILURE) { return; } - + if (php_check_open_basedir(str TSRMLS_CC)) { + RETURN_FALSE; + } ret = VCWD_CHDIR(str); if (ret != 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, %s (errno %d), strerror(errno), errno); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c
pollita Mon Oct 2 17:45:30 2006 UTC Modified files: /php-src/ext/standard dir.c Log: Switch opendir/chroot/chdir to new path_param API and upgrade scandir() for PHP6 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dir.c?r1=1.155r2=1.156diff_format=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.155 php-src/ext/standard/dir.c:1.156 --- php-src/ext/standard/dir.c:1.155Sat Sep 23 12:32:32 2006 +++ php-src/ext/standard/dir.c Mon Oct 2 17:45:30 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.155 2006/09/23 12:32:32 tony2001 Exp $ */ +/* $Id: dir.c,v 1.156 2006/10/02 17:45:30 pollita Exp $ */ /* {{{ includes/startup/misc */ @@ -178,36 +178,32 @@ /* {{{ internal functions */ static void _php_do_opendir(INTERNAL_FUNCTION_PARAMETERS, int createobject) { - UChar *udir; + zval **ppdir; + UChar *udir = NULL; char *dir; int dir_len, udir_len; - zend_uchar dir_type; zval *zcontext = NULL; php_stream_context *context = NULL; php_stream *dirp; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, t|r, dir, dir_len, dir_type, zcontext) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, Z|r, ppdir, zcontext) == FAILURE) { return; } RETVAL_FALSE; - /* Save for later */ - udir = (UChar*)dir; - udir_len = dir_len; - - if (zcontext) { - context = php_stream_context_from_zval(zcontext, 0); + if (createobject Z_TYPE_PP(ppdir) == IS_UNICODE) { + /* Save for later */ + udir = eustrndup(Z_USTRVAL_PP(ppdir), Z_USTRLEN_PP(ppdir)); + udir_len = Z_USTRLEN_PP(ppdir); } - if (dir_type == IS_UNICODE) { - if (FAILURE == php_stream_path_encode(NULL, dir, dir_len, udir, udir_len, REPORT_ERRORS, context)) { - goto opendir_cleanup; - } + context = php_stream_context_from_zval(zcontext, 0); + if (FAILURE == php_stream_path_param_encode(ppdir, dir, dir_len, REPORT_ERRORS, context)) { + goto opendir_cleanup; } dirp = php_stream_opendir(dir, REPORT_ERRORS, context); - if (dirp == NULL) { goto opendir_cleanup; } @@ -216,8 +212,11 @@ if (createobject) { object_init_ex(return_value, dir_class_entry_ptr); - if (dir_type == IS_UNICODE) { - add_property_unicodel(return_value, path, udir, udir_len, 1); + if (udir) { + add_property_unicodel(return_value, path, udir, udir_len, 0); + + /* Avoid auto-cleanup */ + udir = NULL; } else { add_property_stringl(return_value, path, dir, dir_len, 1); } @@ -228,8 +227,8 @@ } opendir_cleanup: - if (dir_type == IS_UNICODE) { - efree(dir); + if (udir) { + efree(udir); } } /* }}} */ @@ -272,25 +271,16 @@ Change root directory */ PHP_FUNCTION(chroot) { + zval **ppstr; char *str; int ret, str_len; - zend_uchar str_type; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, t, str, str_len, str_type) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, Z, ppstr) == FAILURE || + php_stream_path_param_encode(ppstr, str, str_len, REPORT_ERRORS, FG(default_context)) == FAILURE) { return; } - - if (str_type == IS_UNICODE) { - if (FAILURE == php_stream_path_encode(NULL, str, str_len, (UChar*)str, str_len, REPORT_ERRORS, FG(default_context))) { - RETURN_FALSE; - } - } ret = chroot(str); - if (str_type == IS_UNICODE) { - efree(str); - } - if (ret != 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, %s (errno %d), strerror(errno), errno); RETURN_FALSE; @@ -312,25 +302,16 @@ Change the current directory */ PHP_FUNCTION(chdir) { + zval **ppstr; char *str; int ret, str_len; - zend_uchar str_type; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, t, str, str_len, str_type) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, Z, ppstr) == FAILURE || + php_stream_path_param_encode(ppstr, str, str_len, REPORT_ERRORS, FG(default_context)) == FAILURE) { return; } - if (str_type == IS_UNICODE) { - if (FAILURE == php_stream_path_encode(NULL, str, str_len, (UChar*)str, str_len, REPORT_ERRORS, FG(default_context))) { - RETURN_FALSE; -
[PHP-CVS] cvs: php-src /ext/standard dir.c
pollita Mon Oct 2 18:14:43 2006 UTC Modified files: /php-src/ext/standard dir.c Log: Update glob() for PHP6 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dir.c?r1=1.156r2=1.157diff_format=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.156 php-src/ext/standard/dir.c:1.157 --- php-src/ext/standard/dir.c:1.156Mon Oct 2 17:45:30 2006 +++ php-src/ext/standard/dir.c Mon Oct 2 18:14:42 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.156 2006/10/02 17:45:30 pollita Exp $ */ +/* $Id: dir.c,v 1.157 2006/10/02 18:14:42 pollita Exp $ */ /* {{{ includes/startup/misc */ @@ -377,7 +377,7 @@ /* }}} */ #ifdef HAVE_GLOB -/* {{{ proto array glob(string pattern [, int flags]) +/* {{{ proto array glob(string pattern [, int flags]) U Find pathnames matching a pattern */ PHP_FUNCTION(glob) { @@ -387,6 +387,7 @@ char work_pattern[MAXPATHLEN]; char *result; #endif + zval **pppattern; char *pattern = NULL; int pattern_len; long flags = 0; @@ -394,8 +395,10 @@ unsigned int n; int ret; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|l, pattern, pattern_len, flags) == FAILURE) + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, Z|l, pppattern, flags) == FAILURE || + php_stream_path_param_encode(pppattern, pattern, pattern_len, REPORT_ERRORS, FG(default_context)) == FAILURE) { return; + } #ifdef ZTS if (!IS_ABSOLUTE_PATH(pattern, pattern_len)) { @@ -469,7 +472,20 @@ continue; } } - add_next_index_rt_string(return_value, globbuf.gl_pathv[n]+cwd_skip, 1); + if (UG(unicode)) { + UChar *path; + int path_len; + + if (SUCCESS == php_stream_path_decode(php_plain_files_wrapper, path, path_len, globbuf.gl_pathv[n]+cwd_skip, + strlen(globbuf.gl_pathv[n]+cwd_skip), REPORT_ERRORS, FG(default_context))) { + add_next_index_unicodel(return_value, path, path_len, 0); + } else { + /* Fallback on string version, path_decode will emit warning */ + add_next_index_string(return_value, globbuf.gl_pathv[n]+cwd_skip, 1); + } + } else { + add_next_index_string(return_value, globbuf.gl_pathv[n]+cwd_skip, 1); + } } globfree(globbuf); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c
tony2001Sat Sep 23 12:32:32 2006 UTC Modified files: /php-src/ext/standard dir.c Log: add missing parameter to opendir() and fix segfault http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dir.c?r1=1.154r2=1.155diff_format=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.154 php-src/ext/standard/dir.c:1.155 --- php-src/ext/standard/dir.c:1.154Fri Sep 22 23:57:38 2006 +++ php-src/ext/standard/dir.c Sat Sep 23 12:32:32 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.154 2006/09/22 23:57:38 pollita Exp $ */ +/* $Id: dir.c,v 1.155 2006/09/23 12:32:32 tony2001 Exp $ */ /* {{{ includes/startup/misc */ @@ -186,7 +186,7 @@ php_stream_context *context = NULL; php_stream *dirp; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, t|r, dir, dir_len, zcontext) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, t|r, dir, dir_len, dir_type, zcontext) == FAILURE) { return; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c
pollita Fri Sep 22 23:57:38 2006 UTC Modified files: /php-src/ext/standard dir.c Log: PHP6 Updates http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dir.c?r1=1.153r2=1.154diff_format=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.153 php-src/ext/standard/dir.c:1.154 --- php-src/ext/standard/dir.c:1.153Sun Feb 19 04:29:41 2006 +++ php-src/ext/standard/dir.c Fri Sep 22 23:57:38 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.153 2006/02/19 04:29:41 andi Exp $ */ +/* $Id: dir.c,v 1.154 2006/09/22 23:57:38 pollita Exp $ */ /* {{{ includes/startup/misc */ @@ -178,40 +178,63 @@ /* {{{ internal functions */ static void _php_do_opendir(INTERNAL_FUNCTION_PARAMETERS, int createobject) { - char *dirname; - int dir_len; + UChar *udir; + char *dir; + int dir_len, udir_len; + zend_uchar dir_type; zval *zcontext = NULL; php_stream_context *context = NULL; php_stream *dirp; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|r, dirname, dir_len, zcontext) == FAILURE) { - RETURN_NULL(); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, t|r, dir, dir_len, zcontext) == FAILURE) { + return; } + RETVAL_FALSE; + + /* Save for later */ + udir = (UChar*)dir; + udir_len = dir_len; + if (zcontext) { context = php_stream_context_from_zval(zcontext, 0); } - - dirp = php_stream_opendir(dirname, REPORT_ERRORS, context); + + if (dir_type == IS_UNICODE) { + if (FAILURE == php_stream_path_encode(NULL, dir, dir_len, udir, udir_len, REPORT_ERRORS, context)) { + goto opendir_cleanup; + } + } + + dirp = php_stream_opendir(dir, REPORT_ERRORS, context); if (dirp == NULL) { - RETURN_FALSE; + goto opendir_cleanup; } php_set_default_dir(dirp-rsrc_id TSRMLS_CC); if (createobject) { object_init_ex(return_value, dir_class_entry_ptr); - add_property_rt_stringl(return_value, path, dirname, dir_len, 1); + if (dir_type == IS_UNICODE) { + add_property_unicodel(return_value, path, udir, udir_len, 1); + } else { + add_property_stringl(return_value, path, dir, dir_len, 1); + } add_property_resource(return_value, handle, dirp-rsrc_id); php_stream_auto_cleanup(dirp); /* so we don't get warnings under debug */ } else { php_stream_to_zval(dirp, return_value); } + +opendir_cleanup: + if (dir_type == IS_UNICODE) { + efree(dir); + } } /* }}} */ -/* {{{ proto mixed opendir(string path[, resource context]) +/* {{{ proto mixed opendir(string path[, resource context]) U Open a directory and return a dir_handle */ PHP_FUNCTION(opendir) { @@ -219,7 +242,7 @@ } /* }}} */ -/* {{{ proto object dir(string directory[, resource context]) +/* {{{ proto object dir(string directory[, resource context]) U Directory class with properties, handle and class and methods read, rewind and close */ PHP_FUNCTION(getdir) { @@ -227,7 +250,7 @@ } /* }}} */ -/* {{{ proto void closedir([resource dir_handle]) +/* {{{ proto void closedir([resource dir_handle]) U Close directory connection identified by the dir_handle */ PHP_FUNCTION(closedir) { @@ -245,18 +268,28 @@ /* }}} */ #if defined(HAVE_CHROOT) !defined(ZTS) ENABLE_CHROOT_FUNC -/* {{{ proto bool chroot(string directory) +/* {{{ proto bool chroot(string directory) U Change root directory */ PHP_FUNCTION(chroot) { char *str; int ret, str_len; + zend_uchar str_type; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, str, str_len) == FAILURE) { - RETURN_FALSE; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, t, str, str_len, str_type) == FAILURE) { + return; + } + + if (str_type == IS_UNICODE) { + if (FAILURE == php_stream_path_encode(NULL, str, str_len, (UChar*)str, str_len, REPORT_ERRORS, FG(default_context))) { + RETURN_FALSE; + } } ret = chroot(str); + if (str_type == IS_UNICODE) { + efree(str); + } if (ret != 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, %s (errno %d), strerror(errno), errno); @@ -275,18 +308,28 @@ /* }}} */ #endif -/* {{{ proto bool chdir(string directory) +/* {{{ proto bool chdir(string directory) U Change the current directory */ PHP_FUNCTION(chdir) { char *str; int ret, str_len; + zend_uchar str_type;
[PHP-CVS] cvs: php-src /ext/standard dir.c
hholzgraSun Jun 12 03:53:25 2005 EDT Modified files: /php-src/ext/standard dir.c Log: Support for GLOB_ERR so that glob() reports permission problems (Bug #28355) http://cvs.php.net/diff.php/php-src/ext/standard/dir.c?r1=1.145r2=1.146ty=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.145 php-src/ext/standard/dir.c:1.146 --- php-src/ext/standard/dir.c:1.145Sat Jun 11 21:13:24 2005 +++ php-src/ext/standard/dir.c Sun Jun 12 03:53:24 2005 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.145 2005/06/12 01:13:24 hholzgra Exp $ */ +/* $Id: dir.c,v 1.146 2005/06/12 07:53:24 hholzgra Exp $ */ /* {{{ includes/startup/misc */ @@ -155,6 +155,9 @@ #ifdef GLOB_NOESCAPE REGISTER_LONG_CONSTANT(GLOB_NOESCAPE, GLOB_NOESCAPE, CONST_CS | CONST_PERSISTENT); #endif +#ifdef GLOB_ERR + REGISTER_LONG_CONSTANT(GLOB_ERR, GLOB_ERR, CONST_CS | CONST_PERSISTENT); +#endif #ifndef GLOB_ONLYDIR #define GLOB_ONLYDIR (130) @@ -395,10 +398,14 @@ if (0 != (ret = glob(pattern, flags GLOB_FLAGMASK, NULL, globbuf))) { #ifdef GLOB_NOMATCH if (GLOB_NOMATCH == ret) { - /* Linux handles no matches as an error condition, but FreeBSD -* doesn't. This ensure that if no match is found, an empty array -* is always returned so it can be used without worrying in e.g. -* foreach() */ + /* Some glob implementation simply return no data if no matches + were found, others return the GLOB_NOMATCH error code. + We don't want to treat GLOB_NOMATCH as an error condition + so that PHP glob() behaves the same on both types of + implementations and so that 'foreach (glob() as ...' + can be used for simple glob() calls without further error + checking. + */ array_init(return_value); return; } @@ -424,7 +431,7 @@ array_init(return_value); for (n = 0; n globbuf.gl_pathc; n++) { - /* we need to this everytime since GLOB_ONLYDIR does not guarantee that + /* we need to do this everytime since GLOB_ONLYDIR does not guarantee that * all directories will be filtered. GNU libc documentation states the * following: * If the information about the type of the file is easily available -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c
hholzgraSat Jun 11 20:59:08 2005 EDT Modified files: /php-src/ext/standard dir.c Log: Removed bogus fix for bug #28355 (it was dead code anyway) http://cvs.php.net/diff.php/php-src/ext/standard/dir.c?r1=1.143r2=1.144ty=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.143 php-src/ext/standard/dir.c:1.144 --- php-src/ext/standard/dir.c:1.143Wed Feb 23 13:53:09 2005 +++ php-src/ext/standard/dir.c Sat Jun 11 20:59:04 2005 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.143 2005/02/23 18:53:09 iliaa Exp $ */ +/* $Id: dir.c,v 1.144 2005/06/12 00:59:04 hholzgra Exp $ */ /* {{{ includes/startup/misc */ @@ -399,9 +399,6 @@ * doesn't. This ensure that if no match is found, an empty array * is always returned so it can be used without worrying in e.g. * foreach() */ -#ifndef __linux__ - RETURN_FALSE; -#else array_init(return_value); return; #endif -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c
hholzgraSat Jun 11 21:13:25 2005 EDT Modified files: /php-src/ext/standard dir.c Log: thinko fix (E_COMMIT_AFTER_MIDNIGHT) http://cvs.php.net/diff.php/php-src/ext/standard/dir.c?r1=1.144r2=1.145ty=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.144 php-src/ext/standard/dir.c:1.145 --- php-src/ext/standard/dir.c:1.144Sat Jun 11 20:59:04 2005 +++ php-src/ext/standard/dir.c Sat Jun 11 21:13:24 2005 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.144 2005/06/12 00:59:04 hholzgra Exp $ */ +/* $Id: dir.c,v 1.145 2005/06/12 01:13:24 hholzgra Exp $ */ /* {{{ includes/startup/misc */ @@ -401,7 +401,6 @@ * foreach() */ array_init(return_value); return; -#endif } #endif RETURN_FALSE; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c
iliaa Wed Feb 23 13:53:09 2005 EDT Modified files: /php-src/ext/standard dir.c Log: Fixed compiler warning. http://cvs.php.net/diff.php/php-src/ext/standard/dir.c?r1=1.142r2=1.143ty=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.142 php-src/ext/standard/dir.c:1.143 --- php-src/ext/standard/dir.c:1.142Mon Feb 21 19:24:13 2005 +++ php-src/ext/standard/dir.c Wed Feb 23 13:53:09 2005 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.142 2005/02/22 00:24:13 iliaa Exp $ */ +/* $Id: dir.c,v 1.143 2005/02/23 18:53:09 iliaa Exp $ */ /* {{{ includes/startup/misc */ @@ -462,7 +462,7 @@ char *dirn; int dirn_len; long flags = 0; - php_stream_dirent **namelist; + char **namelist; int n, i; zval *zcontext = NULL; php_stream_context *context = 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 dir.c /main php_streams.h /main/streams streams.c
iliaa Mon Feb 21 19:24:13 2005 EDT Modified files: /php-src/main php_streams.h /php-src/main/streams streams.c /php-src/ext/standard dir.c Log: Fixed bug #31515 (Improve performance of scandir() by factor of 10 or so). http://cvs.php.net/diff.php/php-src/main/php_streams.h?r1=1.100r2=1.101ty=u Index: php-src/main/php_streams.h diff -u php-src/main/php_streams.h:1.100 php-src/main/php_streams.h:1.101 --- php-src/main/php_streams.h:1.100Sun Feb 6 18:17:09 2005 +++ php-src/main/php_streams.h Mon Feb 21 19:24:13 2005 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_streams.h,v 1.100 2005/02/06 23:17:09 wez Exp $ */ +/* $Id: php_streams.h,v 1.101 2005/02/22 00:24:13 iliaa Exp $ */ #ifndef PHP_STREAMS_H #define PHP_STREAMS_H @@ -328,11 +328,11 @@ #define php_stream_closedir(dirstream) php_stream_close((dirstream)) #define php_stream_rewinddir(dirstream)php_stream_rewind((dirstream)) -PHPAPI int php_stream_dirent_alphasort(const php_stream_dirent **a, const php_stream_dirent **b); -PHPAPI int php_stream_dirent_alphasortr(const php_stream_dirent **a, const php_stream_dirent **b); +PHPAPI int php_stream_dirent_alphasort(const char **a, const char **b); +PHPAPI int php_stream_dirent_alphasortr(const char **a, const char **b); -PHPAPI int _php_stream_scandir(char *dirname, php_stream_dirent **namelist[], int flags, php_stream_context *context, - int (*compare) (const php_stream_dirent **a, const php_stream_dirent **b) TSRMLS_DC); +PHPAPI int _php_stream_scandir(char *dirname, char **namelist[], int flags, php_stream_context *context, + int (*compare) (const char **a, const char **b) TSRMLS_DC); #define php_stream_scandir(dirname, namelist, context, compare) _php_stream_scandir((dirname), (namelist), 0, (context), (compare) TSRMLS_CC) PHPAPI int _php_stream_set_option(php_stream *stream, int option, int value, void *ptrparam TSRMLS_DC); http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.70r2=1.71ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.70 php-src/main/streams/streams.c:1.71 --- php-src/main/streams/streams.c:1.70 Mon Nov 15 18:43:12 2004 +++ php-src/main/streams/streams.c Mon Feb 21 19:24:13 2005 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.70 2004/11/15 23:43:12 iliaa Exp $ */ +/* $Id: streams.c,v 1.71 2005/02/22 00:24:13 iliaa Exp $ */ #define _GNU_SOURCE #include php.h @@ -1944,28 +1944,28 @@ /* {{{ php_stream_dirent_alphasort */ -PHPAPI int php_stream_dirent_alphasort(const php_stream_dirent **a, const php_stream_dirent **b) +PHPAPI int php_stream_dirent_alphasort(const char **a, const char **b) { - return strcoll((*a)-d_name,(*b)-d_name); + return strcoll(*a, *b); } /* }}} */ /* {{{ php_stream_dirent_alphasortr */ -PHPAPI int php_stream_dirent_alphasortr(const php_stream_dirent **a, const php_stream_dirent **b) +PHPAPI int php_stream_dirent_alphasortr(const char **a, const char **b) { - return strcoll((*b)-d_name,(*a)-d_name); + return strcoll(*b, *a); } /* }}} */ /* {{{ php_stream_scandir */ -PHPAPI int _php_stream_scandir(char *dirname, php_stream_dirent **namelist[], int flags, php_stream_context *context, - int (*compare) (const php_stream_dirent **a, const php_stream_dirent **b) TSRMLS_DC) +PHPAPI int _php_stream_scandir(char *dirname, char **namelist[], int flags, php_stream_context *context, + int (*compare) (const char **a, const char **b) TSRMLS_DC) { php_stream *stream; php_stream_dirent sdp; - php_stream_dirent **vector = NULL; + char **vector = NULL; int vector_size = 0; int nfiles = 0; @@ -1985,11 +1985,10 @@ } else { vector_size *= 2; } - vector = (php_stream_dirent **) erealloc(vector, vector_size * sizeof(php_stream_dirent *)); + vector = (char **) erealloc(vector, vector_size * sizeof(char *)); } - vector[nfiles] = emalloc(sizeof(php_stream_dirent)); - memcpy(vector[nfiles], sdp, sizeof(sdp)); + vector[nfiles] = estrdup(sdp.d_name); nfiles++; } @@ -1998,7 +1997,7 @@ *namelist = vector; if (compare) { - qsort(*namelist, nfiles, sizeof(php_stream_dirent *), (int(*)(const void *, const void *))compare); + qsort(*namelist, nfiles, sizeof(char *), (int(*)(const void *, const void *))compare); } return nfiles; } http://cvs.php.net/diff.php/php-src/ext/standard/dir.c?r1=1.141r2=1.142ty=u Index: php-src/ext/standard/dir.c diff -u
[PHP-CVS] cvs: php-src /ext/standard dir.c
iliaa Sun Jun 6 12:21:12 2004 EDT Modified files: /php-src/ext/standard dir.c Log: Fixed bug #28649 (Proper glob() return value on Linux when there are no matches). http://cvs.php.net/diff.php/php-src/ext/standard/dir.c?r1=1.138r2=1.139ty=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.138 php-src/ext/standard/dir.c:1.139 --- php-src/ext/standard/dir.c:1.138Tue May 11 09:34:19 2004 +++ php-src/ext/standard/dir.c Sun Jun 6 12:21:11 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.138 2004/05/11 13:34:19 iliaa Exp $ */ +/* $Id: dir.c,v 1.139 2004/06/06 16:21:11 iliaa Exp $ */ /* {{{ includes/startup/misc */ @@ -400,7 +400,7 @@ * doesn't. This ensure that if no match is found, an empty array * is always returned so it can be used without worrying in e.g. * foreach() */ -#if __linux__ +#ifndef __linux__ RETURN_FALSE; #else array_init(return_value); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c
iliaa Tue May 11 09:34:19 2004 EDT Modified files: /php-src/ext/standard dir.c Log: Fixed bug #28355 (glob() does not return error on Linux when it does not have permission to open the directory). http://cvs.php.net/diff.php/php-src/ext/standard/dir.c?r1=1.137r2=1.138ty=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.137 php-src/ext/standard/dir.c:1.138 --- php-src/ext/standard/dir.c:1.137Sun May 9 15:01:13 2004 +++ php-src/ext/standard/dir.c Tue May 11 09:34:19 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.137 2004/05/09 19:01:13 iliaa Exp $ */ +/* $Id: dir.c,v 1.138 2004/05/11 13:34:19 iliaa Exp $ */ /* {{{ includes/startup/misc */ @@ -400,8 +400,12 @@ * doesn't. This ensure that if no match is found, an empty array * is always returned so it can be used without worrying in e.g. * foreach() */ +#if __linux__ + RETURN_FALSE; +#else array_init(return_value); return; +#endif } #endif RETURN_FALSE; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c
iliaa Sun May 9 15:01:14 2004 EDT Modified files: /php-src/ext/standard dir.c Log: Fixed bug #28289 (incorrect resolving of relative paths by glob() in windows). http://cvs.php.net/diff.php/php-src/ext/standard/dir.c?r1=1.136r2=1.137ty=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.136 php-src/ext/standard/dir.c:1.137 --- php-src/ext/standard/dir.c:1.136Tue Mar 16 18:23:17 2004 +++ php-src/ext/standard/dir.c Sun May 9 15:01:13 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.136 2004/03/16 23:23:17 iliaa Exp $ */ +/* $Id: dir.c,v 1.137 2004/05/09 19:01:13 iliaa Exp $ */ /* {{{ includes/startup/misc */ @@ -379,11 +379,13 @@ if (!result) { cwd[0] = '\0'; } - cwd_skip = strlen(cwd)+1; #ifdef PHP_WIN32 - if (IS_SLASH(cwd[0]) !IS_UNC_PATH(pattern, pattern_len)) { + if (!IS_SLASH(cwd[0])) { cwd[2] = '\0'; + cwd_skip = 3; } +#else + cwd_skip = strlen(cwd)+1; #endif snprintf(work_pattern, MAXPATHLEN, %s%c%s, cwd, DEFAULT_SLASH, pattern); pattern = work_pattern; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c /main/streams plain_wrapper.c
iliaa Tue Mar 16 18:23:18 2004 EDT Modified files: /php-src/main/streams plain_wrapper.c /php-src/ext/standard dir.c Log: Fixed bug #27498 (bogus safe_mode error on nonexistent directories for chdir() and opendir() functions). http://cvs.php.net/diff.php/php-src/main/streams/plain_wrapper.c?r1=1.34r2=1.35ty=u Index: php-src/main/streams/plain_wrapper.c diff -u php-src/main/streams/plain_wrapper.c:1.34 php-src/main/streams/plain_wrapper.c:1.35 --- php-src/main/streams/plain_wrapper.c:1.34 Tue Jan 20 21:28:50 2004 +++ php-src/main/streams/plain_wrapper.cTue Mar 16 18:23:16 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: plain_wrapper.c,v 1.34 2004/01/21 02:28:50 iliaa Exp $ */ +/* $Id: plain_wrapper.c,v 1.35 2004/03/16 23:23:16 iliaa Exp $ */ #include php.h #include php_globals.h @@ -856,7 +856,7 @@ return NULL; } - if (PG(safe_mode) (!php_checkuid(path, NULL, CHECKUID_ALLOW_ONLY_FILE))) { + if (PG(safe_mode) (!php_checkuid(path, NULL, CHECKUID_CHECK_FILE_AND_DIR))) { return NULL; } http://cvs.php.net/diff.php/php-src/ext/standard/dir.c?r1=1.135r2=1.136ty=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.135 php-src/ext/standard/dir.c:1.136 --- php-src/ext/standard/dir.c:1.135Mon Mar 1 00:40:14 2004 +++ php-src/ext/standard/dir.c Tue Mar 16 18:23:17 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.135 2004/03/01 05:40:14 pollita Exp $ */ +/* $Id: dir.c,v 1.136 2004/03/16 23:23:17 iliaa Exp $ */ /* {{{ includes/startup/misc */ @@ -283,7 +283,7 @@ RETURN_FALSE; } - if (PG(safe_mode) !php_checkuid(str, NULL, CHECKUID_ALLOW_ONLY_FILE)) { + if (PG(safe_mode) !php_checkuid(str, NULL, CHECKUID_CHECK_FILE_AND_DIR)) { RETURN_FALSE; } ret = VCWD_CHDIR(str); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c
pollita Mon Mar 1 00:40:15 2004 EDT Modified files: /php-src/ext/standard dir.c Log: context parameter for opendir() and dir() http://cvs.php.net/diff.php/php-src/ext/standard/dir.c?r1=1.134r2=1.135ty=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.134 php-src/ext/standard/dir.c:1.135 --- php-src/ext/standard/dir.c:1.134Wed Feb 25 15:16:26 2004 +++ php-src/ext/standard/dir.c Mon Mar 1 00:40:14 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.134 2004/02/25 20:16:26 abies Exp $ */ +/* $Id: dir.c,v 1.135 2004/03/01 05:40:14 pollita Exp $ */ /* {{{ includes/startup/misc */ @@ -175,15 +175,21 @@ /* {{{ internal functions */ static void _php_do_opendir(INTERNAL_FUNCTION_PARAMETERS, int createobject) { - pval **arg; + char *dirname; + long dir_len; + zval *zcontext = NULL; + php_stream_context *context = NULL; php_stream *dirp; - - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, arg) == FAILURE) { - WRONG_PARAM_COUNT; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|r, dirname, dir_len, zcontext) == FAILURE) { + RETURN_NULL(); + } + + if (zcontext) { + context = php_stream_context_from_zval(zcontext, 0); } - convert_to_string_ex(arg); - dirp = php_stream_opendir(Z_STRVAL_PP(arg), ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL); + dirp = php_stream_opendir(dirname, ENFORCE_SAFE_MODE|REPORT_ERRORS, context); if (dirp == NULL) { RETURN_FALSE; @@ -193,7 +199,7 @@ if (createobject) { object_init_ex(return_value, dir_class_entry_ptr); - add_property_stringl(return_value, path, Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), 1); + add_property_stringl(return_value, path, dirname, dir_len, 1); add_property_resource(return_value, handle, dirp-rsrc_id); php_stream_auto_cleanup(dirp); /* so we don't get warnings under debug */ } else { @@ -202,7 +208,7 @@ } /* }}} */ -/* {{{ proto mixed opendir(string path) +/* {{{ proto mixed opendir(string path[, resource context]) Open a directory and return a dir_handle */ PHP_FUNCTION(opendir) { @@ -210,7 +216,7 @@ } /* }}} */ -/* {{{ proto object dir(string directory) +/* {{{ proto object dir(string directory[, resource context]) Directory class with properties, handle and class and methods read, rewind and close */ PHP_FUNCTION(getdir) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c /main php_streams.h /main/streams streams.c
pollita Wed Jan 28 17:21:55 2004 EDT Modified files: /php-src/ext/standard dir.c /php-src/main php_streams.h /php-src/main/streams streams.c Log: 'Bug Fix': scandir, being a new function in PHP5 should have always been wrapper aware. http://cvs.php.net/diff.php/php-src/ext/standard/dir.c?r1=1.132r2=1.133ty=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.132 php-src/ext/standard/dir.c:1.133 --- php-src/ext/standard/dir.c:1.132Thu Jan 8 03:17:31 2004 +++ php-src/ext/standard/dir.c Wed Jan 28 17:21:53 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.132 2004/01/08 08:17:31 andi Exp $ */ +/* $Id: dir.c,v 1.133 2004/01/28 22:21:53 pollita Exp $ */ /* {{{ includes/startup/misc */ @@ -444,74 +444,45 @@ /* }}} */ #endif -/* {{{ php_alphasortr -*/ -static int php_alphasortr(const struct dirent **a, const struct dirent **b) -{ - return strcoll((*b)-d_name, (*a)-d_name); -} -/* }}} */ - -/* {{{ proto array scandir(string dir [, int sorting_order]) +/* {{{ proto array scandir(string dir [, int sorting_order [, resource context]]) List files directories inside the specified path */ PHP_FUNCTION(scandir) { char *dirn; int dirn_len; int flags = 0; - char *path; - struct dirent **namelist; + php_stream_dirent **namelist; int n, i; + zval *zcontext = NULL; + php_stream_context *context = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|l, dirn, dirn_len, flags) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|lr, dirn, dirn_len, flags, zcontext) == FAILURE) { return; } -#ifdef ZTS - if (!IS_ABSOLUTE_PATH(dirn, dirn_len)) { - path = expand_filepath(dirn, NULL TSRMLS_CC); - } else -#endif - path = dirn; - - if (PG(safe_mode) (!php_checkuid(path, NULL, CHECKUID_CHECK_FILE_AND_DIR))) { - RETVAL_FALSE; - goto err; - } - if (php_check_open_basedir(path TSRMLS_CC)) { - RETVAL_FALSE; - goto err; + if (zcontext) { + context = php_stream_context_from_zval(zcontext, 0); } if (!flags) { - n = php_scandir(path, namelist, 0, php_alphasort); + n = php_stream_scandir(dirn, namelist, context, (void *) php_stream_dirent_alphasort); } else { - n = php_scandir(path, namelist, 0, (void *) php_alphasortr); + n = php_stream_scandir(dirn, namelist, context, (void *) php_stream_dirent_alphasortr); } - if (n 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, (errno %d): %s, errno, strerror(errno)); - RETVAL_FALSE; - goto err; + RETURN_FALSE; } array_init(return_value); for (i = 0; i n; i++) { - add_next_index_string(return_value, namelist[i]-d_name, 1); - free(namelist[i]); + add_next_index_string(return_value, namelist[i]-d_name, 0); } if (n) { - free(namelist); + efree(namelist); } - -err: - if (path path != dirn) { - efree(path); - } - - return; } /* }}} */ http://cvs.php.net/diff.php/php-src/main/php_streams.h?r1=1.91r2=1.92ty=u Index: php-src/main/php_streams.h diff -u php-src/main/php_streams.h:1.91 php-src/main/php_streams.h:1.92 --- php-src/main/php_streams.h:1.91 Thu Jan 8 12:33:04 2004 +++ php-src/main/php_streams.h Wed Jan 28 17:21:53 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_streams.h,v 1.91 2004/01/08 17:33:04 sniper Exp $ */ +/* $Id: php_streams.h,v 1.92 2004/01/28 22:21:53 pollita Exp $ */ #ifndef PHP_STREAMS_H #define PHP_STREAMS_H @@ -325,6 +325,13 @@ #define php_stream_closedir(dirstream) php_stream_close((dirstream)) #define php_stream_rewinddir(dirstream)php_stream_rewind((dirstream)) +PHPAPI int php_stream_dirent_alphasort(const php_stream_dirent **a, const php_stream_dirent **b); +PHPAPI int php_stream_dirent_alphasortr(const php_stream_dirent **a, const php_stream_dirent **b); + +PHPAPI int _php_stream_scandir(char *dirname, php_stream_dirent **namelist[], int flags, php_stream_context *context, + int (*compare) (const php_stream_dirent **a, const php_stream_dirent **b) TSRMLS_DC); +#define php_stream_scandir(dirname, namelist, context, compare) _php_stream_scandir((dirname), (namelist), 0, (context), (compare) TSRMLS_CC) + PHPAPI int _php_stream_set_option(php_stream *stream, int option, int value, void *ptrparam TSRMLS_DC); #define php_stream_set_option(stream, option, value, ptrvalue)
[PHP-CVS] cvs: php-src /ext/standard dir.c
moriyoshi Wed Oct 29 13:48:38 2003 EDT Modified files: /php-src/ext/standard dir.c Log: MFB(r-1.109.2.12): A possible fix for bug #26026 Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.129 php-src/ext/standard/dir.c:1.130 --- php-src/ext/standard/dir.c:1.129Fri Sep 26 04:09:55 2003 +++ php-src/ext/standard/dir.c Wed Oct 29 13:48:37 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.129 2003/09/26 08:09:55 hholzgra Exp $ */ +/* $Id: dir.c,v 1.130 2003/10/29 18:48:37 moriyoshi Exp $ */ /* {{{ includes/startup/misc */ @@ -401,7 +401,7 @@ #ifndef GLOB_NOMATCH /* now catch the FreeBSD style of no matches */ - if (!globbuf.gl_pathc) { + if (!globbuf.gl_pathc || !globbuf.gl_pathv) { array_init(return_value); return; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c
moriyoshi Wed Oct 29 16:50:16 2003 EDT Modified files: /php-src/ext/standard dir.c Log: This check's always necessary. Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.130 php-src/ext/standard/dir.c:1.131 --- php-src/ext/standard/dir.c:1.130Wed Oct 29 13:48:37 2003 +++ php-src/ext/standard/dir.c Wed Oct 29 16:50:15 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.130 2003/10/29 18:48:37 moriyoshi Exp $ */ +/* $Id: dir.c,v 1.131 2003/10/29 21:50:15 moriyoshi Exp $ */ /* {{{ includes/startup/misc */ @@ -399,13 +399,11 @@ RETURN_FALSE; } -#ifndef GLOB_NOMATCH /* now catch the FreeBSD style of no matches */ if (!globbuf.gl_pathc || !globbuf.gl_pathv) { array_init(return_value); return; } -#endif /* we assume that any glob pattern will match files from one directory only so checking the dirname of the first match should be sufficient */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c
iliaa Fri Sep 19 22:51:21 2003 EDT Modified files: /php-src/ext/standard dir.c Log: Fixed bug #25583 (Incorrect handling of paths starting with / on win32 inside glob() function). Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.127 php-src/ext/standard/dir.c:1.128 --- php-src/ext/standard/dir.c:1.127Sat Aug 2 09:49:12 2003 +++ php-src/ext/standard/dir.c Fri Sep 19 22:51:20 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.127 2003/08/02 13:49:12 helly Exp $ */ +/* $Id: dir.c,v 1.128 2003/09/20 02:51:20 iliaa Exp $ */ /* {{{ includes/startup/misc */ @@ -373,6 +373,11 @@ cwd[0] = '\0'; } cwd_skip = strlen(cwd)+1; +#ifdef PHP_WIN32 + if (IS_SLASH(cwd[0]) !IS_UNC_PATH(pattern, pattern_len)) { + cwd[2] = '\0'; + } +#endif snprintf(work_pattern, MAXPATHLEN, %s%c%s, cwd, DEFAULT_SLASH, pattern); pattern = work_pattern; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c
helly Sat Aug 2 09:49:12 2003 EDT Modified files: /php-src/ext/standard dir.c Log: Use correct macro Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.126 php-src/ext/standard/dir.c:1.127 --- php-src/ext/standard/dir.c:1.126Wed Jul 23 17:41:44 2003 +++ php-src/ext/standard/dir.c Sat Aug 2 09:49:12 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.126 2003/07/23 21:41:44 iliaa Exp $ */ +/* $Id: dir.c,v 1.127 2003/08/02 13:49:12 helly Exp $ */ /* {{{ includes/startup/misc */ @@ -95,7 +95,7 @@ static zend_function_entry php_dir_class_functions[] = { PHP_FALIAS(close, closedir, NULL) PHP_FALIAS(rewind, rewinddir, NULL) - PHP_STATIC_FE(read, php_if_readdir, NULL) + PHP_NAMED_FE(read, php_if_readdir, NULL) {NULL, NULL, 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 dir.c
iliaa Wed Jul 23 17:41:44 2003 EDT Modified files: /php-src/ext/standard dir.c Log: Fixed GLOB_ONLYDIR to work on GNU libc based system. Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.125 php-src/ext/standard/dir.c:1.126 --- php-src/ext/standard/dir.c:1.125Mon Jul 14 12:23:14 2003 +++ php-src/ext/standard/dir.c Wed Jul 23 17:41:44 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.125 2003/07/14 16:23:14 sniper Exp $ */ +/* $Id: dir.c,v 1.126 2003/07/23 21:41:44 iliaa Exp $ */ /* {{{ includes/startup/misc */ @@ -413,7 +413,14 @@ array_init(return_value); for (n = 0; n globbuf.gl_pathc; n++) { -#ifdef GLOB_EMULATE_ONLYDIR + /* we need to this everytime since GLOB_ONLYDIR does not guarantee that +* all directories will be filtered. GNU libc documentation states the +* following: +* If the information about the type of the file is easily available +* non-directories will be rejected but no extra work will be done to +* determine the information for each file. I.e., the caller must still be +* able to filter directories out. +*/ if (flags GLOB_ONLYDIR) { struct stat s; @@ -425,7 +432,6 @@ continue; } } -#endif add_next_index_string(return_value, globbuf.gl_pathv[n]+cwd_skip, 1); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c
sniper Mon Jul 14 12:23:14 2003 EDT Modified files: /php-src/ext/standard dir.c Log: CS WS fixes Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.124 php-src/ext/standard/dir.c:1.125 --- php-src/ext/standard/dir.c:1.124Fri Jul 4 09:24:47 2003 +++ php-src/ext/standard/dir.c Mon Jul 14 12:23:14 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.124 2003/07/04 13:24:47 hholzgra Exp $ */ +/* $Id: dir.c,v 1.125 2003/07/14 16:23:14 sniper Exp $ */ /* {{{ includes/startup/misc */ @@ -88,7 +88,7 @@ WRONG_PARAM_COUNT; \ } else { \ dirp = (php_stream *) zend_fetch_resource(id TSRMLS_CC, -1, Directory, NULL, 1, php_file_le_stream()); \ - if(!dirp) \ + if (!dirp) \ RETURN_FALSE; \ } @@ -130,9 +130,11 @@ #ifdef ZTS ts_allocate_id(dir_globals_id, sizeof(php_dir_globals), NULL, NULL); #endif + dirsep_str[0] = DEFAULT_SLASH; dirsep_str[1] = '\0'; REGISTER_STRING_CONSTANT(DIRECTORY_SEPARATOR, dirsep_str, CONST_CS|CONST_PERSISTENT); + pathsep_str[0] = ZEND_PATHS_SEPARATOR; pathsep_str[1] = '\0'; REGISTER_STRING_CONSTANT(PATH_SEPARATOR, pathsep_str, CONST_CS|CONST_PERSISTENT); @@ -164,14 +166,13 @@ REGISTER_LONG_CONSTANT(GLOB_ONLYDIR, GLOB_ONLYDIR, CONST_CS | CONST_PERSISTENT); -#endif +#endif /* HAVE_GLOB */ return SUCCESS; } - /* }}} */ -/* {{{ internal functions */ +/* {{{ internal functions */ static void _php_do_opendir(INTERNAL_FUNCTION_PARAMETERS, int createobject) { pval **arg; @@ -199,29 +200,26 @@ php_stream_to_zval(dirp, return_value); } } - /* }}} */ + /* {{{ proto mixed opendir(string path) Open a directory and return a dir_handle */ - PHP_FUNCTION(opendir) { _php_do_opendir(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); } - /* }}} */ + /* {{{ proto object dir(string directory) Directory class with properties, handle and class and methods read, rewind and close */ - PHP_FUNCTION(getdir) { _php_do_opendir(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1); } - /* }}} */ + /* {{{ proto void closedir([resource dir_handle]) Close directory connection identified by the dir_handle */ - PHP_FUNCTION(closedir) { pval **id, **tmp, *myself; @@ -235,13 +233,11 @@ zend_list_delete(dirp-rsrc_id); } - /* }}} */ #if defined(HAVE_CHROOT) !defined(ZTS) ENABLE_CHROOT_FUNC /* {{{ proto bool chroot(string directory) Change root directory */ - PHP_FUNCTION(chroot) { char *str; @@ -267,13 +263,11 @@ RETURN_TRUE; } - /* }}} */ #endif /* {{{ proto bool chdir(string directory) Change the current directory */ - PHP_FUNCTION(chdir) { char *str; @@ -295,11 +289,10 @@ RETURN_TRUE; } - /* }}} */ + /* {{{ proto mixed getcwd(void) Gets the current directory */ - PHP_FUNCTION(getcwd) { char path[MAXPATHLEN]; @@ -313,11 +306,6 @@ ret = VCWD_GETCWD(path, MAXPATHLEN); #elif HAVE_GETWD ret = VCWD_GETWD(path); -/* - * #warning is not ANSI C - * #else - * #warning no proper getcwd support for your site - */ #endif if (ret) { @@ -326,11 +314,10 @@ RETURN_FALSE; } } - /* }}} */ + /* {{{ proto void rewinddir([resource dir_handle]) Rewind dir_handle back to the start */ - PHP_FUNCTION(rewinddir) { pval **id, **tmp, *myself; @@ -344,7 +331,6 @@ /* {{{ proto string readdir([resource dir_handle]) Read directory entry from dir_handle */ - PHP_NAMED_FUNCTION(php_if_readdir) { pval **id, **tmp, *myself; @@ -358,7 +344,6 @@ } RETURN_FALSE; } - /* }}} */ #ifdef HAVE_GLOB @@ -382,7 +367,7 @@ return; #ifdef ZTS - if(!IS_ABSOLUTE_PATH(pattern, pattern_len)) { + if (!IS_ABSOLUTE_PATH(pattern, pattern_len)) { result = VCWD_GETCWD(cwd, MAXPATHLEN); if (!result) { cwd[0] = '\0'; @@ -422,11 +407,10 @@ if (PG(safe_mode) (!php_checkuid(cwd, NULL, CHECKUID_CHECK_FILE_AND_DIR))) { RETURN_FALSE; } - if(php_check_open_basedir(cwd TSRMLS_CC)) { + if (php_check_open_basedir(cwd TSRMLS_CC)) { RETURN_FALSE; } - array_init(return_value); for (n = 0; n globbuf.gl_pathc; n++) { #ifdef GLOB_EMULATE_ONLYDIR @@ -474,7 +458,7 @@ } #ifdef ZTS - if(!IS_ABSOLUTE_PATH(dirn, dirn_len)) { + if (!IS_ABSOLUTE_PATH(dirn, dirn_len)) { path = expand_filepath(dirn, NULL TSRMLS_CC); } else #endif @@ -484,7 +468,7 @@ RETVAL_FALSE; goto err; } - if(php_check_open_basedir(path TSRMLS_CC)) { + if (php_check_open_basedir(path TSRMLS_CC))
[PHP-CVS] cvs: php-src /ext/standard dir.c
hholzgraFri Jul 4 09:24:47 2003 EDT Modified files: /php-src/ext/standard dir.c Log: make sure operator precedence is not playing tricks on us (it worked before on gcc3.2/Linux and with VC++ 6, but not with gcc3.1/MacOSX) Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.123 php-src/ext/standard/dir.c:1.124 --- php-src/ext/standard/dir.c:1.123Thu Jul 3 10:54:03 2003 +++ php-src/ext/standard/dir.c Fri Jul 4 09:24:47 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.123 2003/07/03 14:54:03 hholzgra Exp $ */ +/* $Id: dir.c,v 1.124 2003/07/04 13:24:47 hholzgra Exp $ */ /* {{{ includes/startup/misc */ @@ -437,7 +437,7 @@ continue; } - if (S_IFDIR != s.st_mode S_IFMT) { + if (S_IFDIR != (s.st_mode S_IFMT)) { continue; } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c
hholzgraThu Jul 3 10:34:02 2003 EDT Modified files: /php-src/ext/standard dir.c Log: PHP glob() will now emulate GLOB_ONLYDIR on non-GNU systems Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.121 php-src/ext/standard/dir.c:1.122 --- php-src/ext/standard/dir.c:1.121Tue Jun 10 16:03:37 2003 +++ php-src/ext/standard/dir.c Thu Jul 3 10:34:02 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.121 2003/06/10 20:03:37 imajes Exp $ */ +/* $Id: dir.c,v 1.122 2003/07/03 14:34:02 hholzgra Exp $ */ /* {{{ includes/startup/misc */ @@ -141,9 +141,6 @@ #ifdef GLOB_BRACE REGISTER_LONG_CONSTANT(GLOB_BRACE, GLOB_BRACE, CONST_CS | CONST_PERSISTENT); #endif -#ifdef GLOB_ONLYDIR - REGISTER_LONG_CONSTANT(GLOB_ONLYDIR, GLOB_ONLYDIR, CONST_CS | CONST_PERSISTENT); -#endif #ifdef GLOB_MARK REGISTER_LONG_CONSTANT(GLOB_MARK, GLOB_MARK, CONST_CS | CONST_PERSISTENT); #endif @@ -156,6 +153,17 @@ #ifdef GLOB_NOESCAPE REGISTER_LONG_CONSTANT(GLOB_NOESCAPE, GLOB_NOESCAPE, CONST_CS | CONST_PERSISTENT); #endif + +#ifndef GLOB_ONLYDIR +#define GLOB_ONLYDIR (130) +#define GLOB_EMULATE_ONLYDIR +#define GLOB_FLAGMASK (~GLOB_ONLYDIR) +#else +#define GLOB_FLAGMASK (~0) +#endif + + REGISTER_LONG_CONSTANT(GLOB_ONLYDIR, GLOB_ONLYDIR, CONST_CS | CONST_PERSISTENT); + #endif return SUCCESS; @@ -386,7 +394,7 @@ #endif globbuf.gl_offs = 0; - if (0 != (ret = glob(pattern, flags, NULL, globbuf))) { + if (0 != (ret = glob(pattern, flags GLOB_FLAGMASK, NULL, globbuf))) { #ifdef GLOB_NOMATCH if (GLOB_NOMATCH == ret) { /* Linux handles no matches as an error condition, but FreeBSD @@ -421,6 +429,19 @@ array_init(return_value); for (n = 0; n globbuf.gl_pathc; n++) { +#ifdef GLOB_EMULATE_ONLYDIR + if (flags GLOB_ONLYDIR) { + struct stat s; + + if (0 != stat(globbuf.gl_pathv[n], s)) { + continue; + } + + if (!S_ISDIR(s.st_mode)) { + continue; + } + } +#endif add_next_index_string(return_value, globbuf.gl_pathv[n]+cwd_skip, 1); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dir.c
hholzgraThu Jul 3 10:54:03 2003 EDT Modified files: /php-src/ext/standard dir.c Log: VCWD awareness and (hopefully) windows compile fix Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.122 php-src/ext/standard/dir.c:1.123 --- php-src/ext/standard/dir.c:1.122Thu Jul 3 10:34:02 2003 +++ php-src/ext/standard/dir.c Thu Jul 3 10:54:03 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.122 2003/07/03 14:34:02 hholzgra Exp $ */ +/* $Id: dir.c,v 1.123 2003/07/03 14:54:03 hholzgra Exp $ */ /* {{{ includes/startup/misc */ @@ -433,11 +433,11 @@ if (flags GLOB_ONLYDIR) { struct stat s; - if (0 != stat(globbuf.gl_pathv[n], s)) { + if (0 != VCWD_STAT(globbuf.gl_pathv[n], s)) { continue; } - if (!S_ISDIR(s.st_mode)) { + if (S_IFDIR != s.st_mode S_IFMT) { continue; } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php