Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix loading absolute path libs with LD_LIBRARY_PATH #495

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions framework/delibs/deutil/deDynamicLibrary.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
/* Posix implementation. */

#include <dlfcn.h>
#include <libgen.h>
#include <stdlib.h>

struct deDynamicLibrary_s
{
Expand All @@ -43,18 +41,7 @@ deDynamicLibrary *deDynamicLibrary_open(const char *fileName)
if (!library)
return NULL;

if (getenv("LD_LIBRARY_PATH"))
{
// basename() requires a non-const string because it may modify the its contents, so we cannot pass fileName to
// it directly. The string may be coming from statically allocated memory. E.g. this segfaulted in FreeBSD.
char *aux = deStrdup(fileName);
if (!aux)
return NULL;
library->libHandle = dlopen(basename(aux), RTLD_LAZY);
deFree(aux);
}
else
library->libHandle = dlopen(fileName, RTLD_LAZY);
library->libHandle = dlopen(fileName, RTLD_LAZY);

if (!library->libHandle)
{
Expand Down