From: Stefan Esser Date: Wed, 1 Dec 2004 22:56:20 +0000 (+0000) Subject: MFH X-Git-Tag: php-5.0.3RC2~45 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9bce9725ce839a0ef4acefd667d043d9202fe27e;p=php MFH --- diff --git a/TSRM/tsrm_virtual_cwd.c b/TSRM/tsrm_virtual_cwd.c index d0c741faae..3f8192340f 100644 --- a/TSRM/tsrm_virtual_cwd.c +++ b/TSRM/tsrm_virtual_cwd.c @@ -308,15 +308,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; @@ -332,9 +338,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); }