diff options
Diffstat (limited to 'main/fopen_wrappers.c')
-rw-r--r-- | main/fopen_wrappers.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c index 981c5c5a15..a4aa10fce8 100644 --- a/main/fopen_wrappers.c +++ b/main/fopen_wrappers.c @@ -94,24 +94,24 @@ PHPAPI ZEND_INI_MH(OnUpdateBaseDir) if (stage == PHP_INI_STAGE_STARTUP || stage == PHP_INI_STAGE_SHUTDOWN || stage == PHP_INI_STAGE_ACTIVATE || stage == PHP_INI_STAGE_DEACTIVATE) { /* We're in a PHP_INI_SYSTEM context, no restrictions */ - *p = new_value; + *p = new_value ? new_value->val : NULL; return SUCCESS; } /* Otherwise we're in runtime */ if (!*p || !**p) { /* open_basedir not set yet, go ahead and give it a value */ - *p = new_value; + *p = new_value->val; return SUCCESS; } /* Shortcut: When we have a open_basedir and someone tries to unset, we know it'll fail */ - if (!new_value || !*new_value) { + if (!new_value || !*new_value->val) { return FAILURE; } /* Is the proposed open_basedir at least as restrictive as the current setting? */ - ptr = pathbuf = estrdup(new_value); + ptr = pathbuf = estrdup(new_value->val); while (ptr && *ptr) { end = strchr(ptr, DEFAULT_DIR_SEPARATOR); if (end != NULL) { @@ -128,7 +128,7 @@ PHPAPI ZEND_INI_MH(OnUpdateBaseDir) efree(pathbuf); /* Everything checks out, set it */ - *p = new_value; + *p = new_value->val; return SUCCESS; } @@ -226,12 +226,13 @@ PHPAPI int php_check_specific_open_basedir(const char *basedir, const char *path /* Resolve open_basedir to resolved_basedir */ if (expand_filepath(local_open_basedir, resolved_basedir TSRMLS_CC) != NULL) { + int basedir_len = (int)strlen(basedir); /* Handler for basedirs that end with a / */ - resolved_basedir_len = strlen(resolved_basedir); + resolved_basedir_len = (int)strlen(resolved_basedir); #if defined(PHP_WIN32) || defined(NETWARE) - if (basedir[strlen(basedir) - 1] == PHP_DIR_SEPARATOR || basedir[strlen(basedir) - 1] == '/') { + if (basedir[basedir_len - 1] == PHP_DIR_SEPARATOR || basedir[basedir_len - 1] == '/') { #else - if (basedir[strlen(basedir) - 1] == PHP_DIR_SEPARATOR) { + if (basedir[basedir_len - 1] == PHP_DIR_SEPARATOR) { #endif if (resolved_basedir[resolved_basedir_len - 1] != PHP_DIR_SEPARATOR) { resolved_basedir[resolved_basedir_len] = PHP_DIR_SEPARATOR; @@ -758,10 +759,15 @@ PHPAPI char *expand_filepath_with_mode(const char *filepath, char *real_path, co cwd_state new_state; char cwd[MAXPATHLEN]; int copy_len; + int path_len; if (!filepath[0]) { return NULL; - } else if (IS_ABSOLUTE_PATH(filepath, strlen(filepath))) { + } + + path_len = (int)strlen(filepath); + + if (IS_ABSOLUTE_PATH(filepath, path_len)) { cwd[0] = '\0'; } else { const char *iam = SG(request_info).path_translated; @@ -784,7 +790,7 @@ PHPAPI char *expand_filepath_with_mode(const char *filepath, char *real_path, co /* return a relative file path if for any reason * we cannot cannot getcwd() and the requested, * relatively referenced file is accessible */ - copy_len = strlen(filepath) > MAXPATHLEN - 1 ? MAXPATHLEN - 1 : strlen(filepath); + copy_len = path_len > MAXPATHLEN - 1 ? MAXPATHLEN - 1 : path_len; if (real_path) { memcpy(real_path, filepath, copy_len); real_path[copy_len] = '\0'; |