From 761a8f811de262f10c89961bd3d24a989b279948 Mon Sep 17 00:00:00 2001 From: AlexPeshkoff Date: Fri, 24 May 2019 20:02:30 +0300 Subject: [PATCH] Postfix for CORE-5474, more generic way to check for actual library name --- src/common/os/posix/mod_loader.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/common/os/posix/mod_loader.cpp b/src/common/os/posix/mod_loader.cpp index 9c8ba38ddd..7bddccd55c 100644 --- a/src/common/os/posix/mod_loader.cpp +++ b/src/common/os/posix/mod_loader.cpp @@ -131,16 +131,25 @@ void* DlfcnModule::findSymbol(const Firebird::string& symName) result = dlsym(module, newSym.c_str()); } + if (!result) + return NULL; #ifdef HAVE_DLADDR - if (!PathUtils::isRelative(fileName)) + Dl_info info; + if (!dladdr(result, &info)) + return NULL; + + if (PathUtils::isRelative(fileName) || PathUtils::isRelative(info.dli_fname)) { - Dl_info info; - if (!dladdr(result, &info)) - return NULL; - if (fileName != info.dli_fname) + // check only name (not path) of the library + Firebird::PathName dummyDir, nm1, nm2; + PathUtils::splitLastComponent(dummyDir, nm1, fileName); + PathUtils::splitLastComponent(dummyDir, nm2, info.dli_fname); + if (nm1 != nm2) return NULL; } + else if (fileName != info.dli_fname) + return NULL; #endif return result;