dmitry Tue Jul 10 13:21:11 2007 UTC
Modified files: (Branch: PHP_5_2)
/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.74.2.9.2.31&r2=1.74.2.9.2.32&diff_format=u
Index: TSRM/tsrm_virtual_cwd.c
diff -u TSRM/tsrm_virtual_cwd.c:1.74.2.9.2.31
TSRM/tsrm_virtual_cwd.c:1.74.2.9.2.32
--- TSRM/tsrm_virtual_cwd.c:1.74.2.9.2.31 Tue Jul 3 14:48:01 2007
+++ TSRM/tsrm_virtual_cwd.c Tue Jul 10 13:21:11 2007
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: tsrm_virtual_cwd.c,v 1.74.2.9.2.31 2007/07/03 14:48:01 dmitry Exp $ */
+/* $Id: tsrm_virtual_cwd.c,v 1.74.2.9.2.32 2007/07/10 13:21:11 dmitry Exp $ */
#include <sys/types.h>
#include <sys/stat.h>
@@ -477,11 +477,11 @@
int use_cache;
int use_relative_path = 0;
TSRMLS_FETCH();
-
+
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,8 +769,23 @@
{
cwd_state new_state;
char *retval;
+ char cwd[MAXPATHLEN];
- CWD_STATE_COPY(&new_state, &CWDG(cwd));
+ /* 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;
+ }
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.175.2.3.2.12&r2=1.175.2.3.2.13&diff_format=u
Index: php-src/main/fopen_wrappers.c
diff -u php-src/main/fopen_wrappers.c:1.175.2.3.2.12
php-src/main/fopen_wrappers.c:1.175.2.3.2.13
--- php-src/main/fopen_wrappers.c:1.175.2.3.2.12 Fri Jun 1 13:35:23 2007
+++ php-src/main/fopen_wrappers.c Tue Jul 10 13:21:11 2007
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: fopen_wrappers.c,v 1.175.2.3.2.12 2007/06/01 13:35:23 tony2001 Exp $ */
+/* $Id: fopen_wrappers.c,v 1.175.2.3.2.13 2007/07/10 13:21:11 dmitry Exp $ */
/* {{{ includes
*/
@@ -606,7 +606,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.52.2.1.2.2&r2=1.52.2.1.2.3&diff_format=u
Index: php-src/ext/standard/link.c
diff -u php-src/ext/standard/link.c:1.52.2.1.2.2
php-src/ext/standard/link.c:1.52.2.1.2.3
--- php-src/ext/standard/link.c:1.52.2.1.2.2 Mon Jan 1 09:36:08 2007
+++ php-src/ext/standard/link.c Tue Jul 10 13:21:11 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: link.c,v 1.52.2.1.2.2 2007/01/01 09:36:08 sebastian Exp $ */
+/* $Id: link.c,v 1.52.2.1.2.3 2007/07/10 13:21:11 dmitry Exp $ */
#include "php.h"
#include "php_filestat.h"
@@ -123,6 +123,7 @@
convert_to_string_ex(frompath);
if (!expand_filepath(Z_STRVAL_PP(frompath), source_p TSRMLS_CC) ||
!expand_filepath(Z_STRVAL_PP(topath), dest_p TSRMLS_CC)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "No such file or
directory");
RETURN_FALSE;
}
@@ -179,6 +180,7 @@
convert_to_string_ex(frompath);
if (!expand_filepath(Z_STRVAL_PP(frompath), source_p TSRMLS_CC) ||
!expand_filepath(Z_STRVAL_PP(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.1.2.1&r2=1.1.2.2&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.1.2.1
php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_error1.phpt:1.1.2.2
---
php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_error1.phpt:1.1.2.1
Thu Jul 5 18:53:33 2007
+++ php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_error1.phpt
Tue Jul 10 13:21:11 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