From: Stefan Esser Date: Wed, 1 Dec 2004 22:56:33 +0000 (+0000) Subject: MFH X-Git-Tag: php-4.3.10RC2~22 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8aa0e898011a5bb460e004f536cb569c3f44d6c9;p=php MFH --- diff --git a/TSRM/tsrm_virtual_cwd.c b/TSRM/tsrm_virtual_cwd.c index f1edfe2e85..26104f262f 100644 --- a/TSRM/tsrm_virtual_cwd.c +++ b/TSRM/tsrm_virtual_cwd.c @@ -301,15 +301,21 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func if (path_length == 0) return (0); + if (path_length >= MAXPATHLEN) + return (1); #if !defined(TSRM_WIN32) && !defined(NETWARE) /* cwd_length can be 0 when getcwd() fails. * This can happen under solaris when a dir does not have read permissions * but *does* have execute permissions */ if (IS_ABSOLUTE_PATH(path, path_length) || (state->cwd_length < 1)) { - if (use_realpath && realpath(path, resolved_path)) { - path = resolved_path; - path_length = strlen(path); + if (use_realpath) + if (realpath(path, resolved_path)) { + path = resolved_path; + path_length = strlen(path); + } else { + return 1; + } } } else { /* Concat current directory with relative path and then run realpath() on it */ char *tmp; @@ -325,9 +331,18 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func memcpy(ptr, path, path_length); ptr += path_length; *ptr = '\0'; - if (use_realpath && realpath(tmp, resolved_path)) { - path = resolved_path; - path_length = strlen(path); + if (strlen(tmp) >= MAXPATHLEN) { + free(tmp); + return 1; + } + if (use_realpath) { + if (realpath(tmp, resolved_path)) { + path = resolved_path; + path_length = strlen(path); + } else { + free(tmp); + return 1; + } } free(tmp); }