X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Ftypes%2Fdecl_file.c;h=e9366b79789766ceb4142d113436392bd8418307;hb=698841dfdd4d70d24e0b7af25ac7100bc2cb26a4;hp=89c232346603d6bc62f3e928371714efcfce7206;hpb=2fa436074ca9a5e87f39b696de832fa2188fcfc6;p=m6w6%2Fext-psi diff --git a/src/types/decl_file.c b/src/types/decl_file.c index 89c2323..e9366b7 100644 --- a/src/types/decl_file.c +++ b/src/types/decl_file.c @@ -23,10 +23,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *******************************************************************************/ -#include "php_psi_stdinc.h" +#ifdef HAVE_CONFIG_H +# include "config.h" +#else +# include "php_config.h" +#endif #include "data.h" - -#include +#include "dl.h" void psi_decl_file_dtor(struct psi_decl_file *file) { @@ -42,26 +45,25 @@ void psi_decl_file_dtor(struct psi_decl_file *file) memset(file, 0, sizeof(*file)); } -static inline bool validate_lib(struct psi_data *dst, const char *libname, void **dlopened) +static inline bool validate_lib(struct psi_data *dst, const zend_string *libname, void **dlopened) { - char lib[MAXPATHLEN]; - size_t len; + char lib[PATH_MAX]; + size_t len = PATH_MAX; if (!libname) { /* FIXME: assume stdlib */ return true; - } else if (!strchr(libname, '/')) { - len = snprintf(lib, MAXPATHLEN, "lib%s.%s", libname, PHP_PSI_SHLIB_SUFFIX); - if (MAXPATHLEN == len) { - dst->error(dst, NULL, PSI_WARNING, "Library name too long: '%s'", - libname); - } - lib[len] = 0; - libname = lib; } - if (!(*dlopened = dlopen(libname, RTLD_LAZY | RTLD_LOCAL))) { - dst->error(dst, NULL, PSI_WARNING, "Could not open library '%s': %s.", - libname, dlerror()); + + if (PATH_MAX == psi_dlname(&lib, &len, libname->val)) { + dst->error(dst, NULL, PSI_WARNING, "Library name too long: '%s'", + libname->val); + return false; + } + + if (!(*dlopened = psi_dlopen(lib))) { + dst->error(dst, NULL, PSI_WARNING, "Could not open library '%s': %s", + libname->val, psi_dlerror()); return false; } @@ -71,7 +73,7 @@ static inline bool validate_lib(struct psi_data *dst, const char *libname, void bool psi_decl_file_validate(struct psi_data *dst, struct psi_data *src) { size_t i = 0; - char *libname; + zend_string *libname; void *dlopened; while (psi_plist_get(src->file.libnames, i++, &libname)) { @@ -91,12 +93,14 @@ bool psi_decl_file_validate(struct psi_data *dst, struct psi_data *src) void psi_libs_free(void **dlopened) { if (*dlopened) { - dlclose(*dlopened); + psi_dlclose(*dlopened); + *dlopened = NULL; } } -void psi_names_free(char **name) { +void psi_names_free(zend_string **name) { if (*name) { - free(*name); + zend_string_release(*name); + *name = NULL; } }