summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2005-12-20 14:27:04 +0000
committerIlia Alshanetsky <iliaa@php.net>2005-12-20 14:27:04 +0000
commitec58b74d7ff4909db0e050c8008d93c22402edd3 (patch)
tree52458833f2eb7a13f9cec8a489f8d230b73a7899
parentad97cf20be082884ef41e43a4c147cd8a4295df5 (diff)
downloadphp-git-ec58b74d7ff4909db0e050c8008d93c22402edd3.tar.gz
MFB51: Fixed bug #31347 (is_dir and is_file (incorrectly) return true for any
string greater then 255 characters).
-rw-r--r--TSRM/tsrm_config_common.h2
-rw-r--r--TSRM/tsrm_virtual_cwd.c9
-rw-r--r--main/php.h2
3 files changed, 10 insertions, 3 deletions
diff --git a/TSRM/tsrm_config_common.h b/TSRM/tsrm_config_common.h
index bdd171e619..62a7c8efc0 100644
--- a/TSRM/tsrm_config_common.h
+++ b/TSRM/tsrm_config_common.h
@@ -42,6 +42,8 @@ char *alloca ();
#ifndef MAXPATHLEN
# ifdef PATH_MAX
# define MAXPATHLEN PATH_MAX
+# elif defined(MAX_PATH)
+# define MAXPATHLEN MAX_PATH
# else
# define MAXPATHLEN 256
# endif
diff --git a/TSRM/tsrm_virtual_cwd.c b/TSRM/tsrm_virtual_cwd.c
index baf5843d00..cd2c6d2c5d 100644
--- a/TSRM/tsrm_virtual_cwd.c
+++ b/TSRM/tsrm_virtual_cwd.c
@@ -478,13 +478,14 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
#endif
#if defined(TSRM_WIN32)
{
- char *dummy = NULL;
int new_path_length;
- new_path_length = GetLongPathName(path, dummy, 0) + 1;
+ new_path_length = GetLongPathName(path, NULL, 0);
if (new_path_length == 0) {
return 1;
}
+
+ /* GetLongPathName already counts the \0 */
new_path = (char *) malloc(new_path_length);
if (!new_path) {
return 1;
@@ -856,7 +857,9 @@ CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC)
int retval;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- virtual_file_ex(&new_state, path, NULL, 1);
+ if (virtual_file_ex(&new_state, path, NULL, 1)) {
+ return -1;
+ }
retval = stat(new_state.cwd, buf);
diff --git a/main/php.h b/main/php.h
index d3e13a181e..1639c52db4 100644
--- a/main/php.h
+++ b/main/php.h
@@ -248,6 +248,8 @@ END_EXTERN_C()
#ifndef MAXPATHLEN
# ifdef PATH_MAX
# define MAXPATHLEN PATH_MAX
+# elif defined(MAX_PATH)
+# define MAXPATHLEN MAX_PATH
# else
# define MAXPATHLEN 256 /* Should be safe for any weird systems that do not define it */
# endif