Fixed bug #74866 extension_dir = "./ext" now use current directory for base

This commit is contained in:
Francois Laupretre 2017-07-13 14:27:19 +02:00 committed by Anatol Belski
parent 613102bd67
commit 0782a7fc63
5 changed files with 66 additions and 31 deletions

View file

@ -362,10 +362,12 @@ static void php_load_zend_extension_cb(void *arg)
if (IS_ABSOLUTE_PATH(filename, length)) {
zend_load_extension(filename);
} else {
DL_HANDLE handle;
char *libpath;
char *extension_dir = INI_STR("extension_dir");
int extension_dir_len = (int)strlen(extension_dir);
int slash_suffix = IS_SLASH(extension_dir[extension_dir_len-1]);
char *err1, *err2;
/* Try as filename first */
if (slash_suffix) {
spprintf(&libpath, 0, "%s%s", extension_dir, filename); /* SAFE */
@ -373,7 +375,8 @@ static void php_load_zend_extension_cb(void *arg)
spprintf(&libpath, 0, "%s%c%s", extension_dir, DEFAULT_SLASH, filename); /* SAFE */
}
if (VCWD_ACCESS(libpath, F_OK)) {
handle = (DL_HANDLE)php_load_shlib(libpath, &err1);
if (!handle) {
/* If file does not exist, consider as extension name and build file name */
char *orig_libpath = libpath;
@ -383,18 +386,22 @@ static void php_load_zend_extension_cb(void *arg)
spprintf(&libpath, 0, "%s%c" PHP_SHLIB_EXT_PREFIX "%s." PHP_SHLIB_SUFFIX, extension_dir, DEFAULT_SLASH, filename); /* SAFE */
}
if (VCWD_ACCESS(libpath, F_OK)) {
php_error(E_CORE_WARNING, "Cannot access Zend extension %s (Tried: %s, %s)\n",
filename, orig_libpath, libpath);
handle = (DL_HANDLE)php_load_shlib(libpath, &err2);
if (!handle) {
php_error(E_CORE_WARNING, "Failed loading Zend extension '%s' (tried: %s (%s), %s (%s))",
filename, orig_libpath, err1, libpath, err2);
efree(orig_libpath);
efree(err1);
efree(libpath);
efree(err2);
return;
}
efree(orig_libpath);
efree(err1);
}
zend_load_extension(libpath);
zend_load_extension_handle(handle, libpath);
efree(libpath);
}
}