dmitry Tue Jul 10 13:21:31 2007 UTC Modified files: /TSRM tsrm_virtual_cwd.c /php-src/main fopen_wrappers.c /php-src/ext/standard link.c /php-src/ext/standard/tests/file symlink_link_linkinfo_is_link_error1.phpt Log: Fixed symlink("", "somthing") and link("", "somthing") in ZTS mode http://cvs.php.net/viewvc.cgi/TSRM/tsrm_virtual_cwd.c?r1=1.111&r2=1.112&diff_format=u Index: TSRM/tsrm_virtual_cwd.c diff -u TSRM/tsrm_virtual_cwd.c:1.111 TSRM/tsrm_virtual_cwd.c:1.112 --- TSRM/tsrm_virtual_cwd.c:1.111 Tue Jul 3 14:48:37 2007 +++ TSRM/tsrm_virtual_cwd.c Tue Jul 10 13:21:30 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: tsrm_virtual_cwd.c,v 1.111 2007/07/03 14:48:37 dmitry Exp $ */ +/* $Id: tsrm_virtual_cwd.c,v 1.112 2007/07/10 13:21:30 dmitry Exp $ */ #include <sys/types.h> #include <sys/stat.h> @@ -481,7 +481,7 @@ use_cache = ((use_realpath != CWD_EXPAND) && CWDG(realpath_cache_size_limit)); if (path_length == 0) - return (0); + return (1); if (path_length >= MAXPATHLEN) return (1); @@ -769,9 +769,24 @@ { cwd_state new_state; char *retval; + char cwd[MAXPATHLEN]; + + /* realpath("") returns CWD */ + if (!*path) { + new_state.cwd = (char*)malloc(1); + new_state.cwd[0] = '\0'; + new_state.cwd_length = 0; + if (VCWD_GETCWD(cwd, MAXPATHLEN)) { + path = cwd; + } + } else if (!IS_ABSOLUTE_PATH(path, strlen(path))) { + CWD_STATE_COPY(&new_state, &CWDG(cwd)); + } else { + new_state.cwd = (char*)malloc(1); + new_state.cwd[0] = '\0'; + new_state.cwd_length = 0; + } - CWD_STATE_COPY(&new_state, &CWDG(cwd)); - if (virtual_file_ex(&new_state, path, NULL, CWD_REALPATH)==0) { int len = new_state.cwd_length>MAXPATHLEN-1?MAXPATHLEN-1:new_state.cwd_length; @@ -1202,7 +1217,15 @@ cwd_state new_state; char cwd[MAXPATHLEN]; - if (!IS_ABSOLUTE_PATH(path, strlen(path)) && + /* realpath("") returns CWD */ + if (!*path) { + new_state.cwd = (char*)malloc(1); + new_state.cwd[0] = '\0'; + new_state.cwd_length = 0; + if (VCWD_GETCWD(cwd, MAXPATHLEN)) { + path = cwd; + } + } else if (!IS_ABSOLUTE_PATH(path, strlen(path)) && VCWD_GETCWD(cwd, MAXPATHLEN)) { new_state.cwd = strdup(cwd); new_state.cwd_length = strlen(cwd); http://cvs.php.net/viewvc.cgi/php-src/main/fopen_wrappers.c?r1=1.194&r2=1.195&diff_format=u Index: php-src/main/fopen_wrappers.c diff -u php-src/main/fopen_wrappers.c:1.194 php-src/main/fopen_wrappers.c:1.195 --- php-src/main/fopen_wrappers.c:1.194 Fri Jun 1 13:33:48 2007 +++ php-src/main/fopen_wrappers.c Tue Jul 10 13:21:30 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: fopen_wrappers.c,v 1.194 2007/06/01 13:33:48 tony2001 Exp $ */ +/* $Id: fopen_wrappers.c,v 1.195 2007/07/10 13:21:30 dmitry Exp $ */ /* {{{ includes */ @@ -579,7 +579,9 @@ char cwd[MAXPATHLEN]; char *result; - if (IS_ABSOLUTE_PATH(filepath, strlen(filepath))) { + if (!filepath[0]) { + return NULL; + } else if (IS_ABSOLUTE_PATH(filepath, strlen(filepath))) { cwd[0] = '\0'; } else{ result = VCWD_GETCWD(cwd, MAXPATHLEN); http://cvs.php.net/viewvc.cgi/php-src/ext/standard/link.c?r1=1.59&r2=1.60&diff_format=u Index: php-src/ext/standard/link.c diff -u php-src/ext/standard/link.c:1.59 php-src/ext/standard/link.c:1.60 --- php-src/ext/standard/link.c:1.59 Mon Jan 1 09:29:32 2007 +++ php-src/ext/standard/link.c Tue Jul 10 13:21:31 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: link.c,v 1.59 2007/01/01 09:29:32 sebastian Exp $ */ +/* $Id: link.c,v 1.60 2007/07/10 13:21:31 dmitry Exp $ */ #include "php.h" #include "php_filestat.h" @@ -135,6 +135,7 @@ } if (!expand_filepath(frompath, source_p TSRMLS_CC) || !expand_filepath(topath, dest_p TSRMLS_CC)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "No such file or directory"); RETURN_FALSE; } @@ -185,6 +186,7 @@ } if (!expand_filepath(frompath, source_p TSRMLS_CC) || !expand_filepath(topath, dest_p TSRMLS_CC)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "No such file or directory"); RETURN_FALSE; } http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_error1.phpt?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_error1.phpt diff -u php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_error1.phpt:1.2 php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_error1.phpt:1.3 --- php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_error1.phpt:1.2 Thu Jul 5 18:59:20 2007 +++ php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_error1.phpt Tue Jul 10 13:21:31 2007 @@ -67,6 +67,7 @@ --CLEAN-- <?php unlink(dirname(__FILE__)."/symlink_link_linkinfo_is_link_error1.tmp"); [EMAIL PROTECTED](dirname(__FILE__)."/symlink_link_linkinfo_is_link_link_error1.tmp"); ?> --EXPECTF-- *** Testing symlink() for error conditions ***
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php