From b18efa341f7a5645666ff7839edfd86fc821fee7 Mon Sep 17 00:00:00 2001 From: Joakim Tjernlund Date: Tue, 31 May 2005 11:49:10 +0000 Subject: Fix bug 60 --- ldso/ldso/dl-elf.c | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) (limited to 'ldso/ldso') diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c index 558eeaa20..67d42110c 100644 --- a/ldso/ldso/dl-elf.c +++ b/ldso/ldso/dl-elf.c @@ -139,10 +139,10 @@ static struct elf_resolve * search_for_named_library(const char *name, int secure, const char *path_list, struct dyn_elf **rpnt) { - int i, count = 1; char *path, *path_n; char mylibname[2050]; - struct elf_resolve *tpnt1; + struct elf_resolve *tpnt; + int done = 0; if (path_list==NULL) return NULL; @@ -154,29 +154,32 @@ search_for_named_library(const char *name, int secure, const char *path_list, _dl_exit(0); } - /* Unlike ldd.c, don't bother to eliminate double //s */ - - /* Replace colons with zeros in path_list and count them */ - for(i=_dl_strlen(path); i > 0; i--) { - if (path[i]==':') { - path[i]=0; - count++; - } - } - + /* Replace colons with zeros in path_list */ + /* : at the beginning or end of path maps to CWD */ + /* :: anywhere maps CWD */ + /* "" maps to CWD */ path_n = path; - for (i = 0; i < count; i++) { - _dl_strcpy(mylibname, path_n); - _dl_strcat(mylibname, "/"); - _dl_strcat(mylibname, name); - if ((tpnt1 = _dl_load_elf_shared_library(secure, rpnt, mylibname)) != NULL) - { - return tpnt1; + do { + if (*path == 0) { + *path = ':'; + done = 1; } - path_n += (_dl_strlen(path_n) + 1); - } + if (*path == ':') { + *path = 0; + if (*path_n) + _dl_strcpy(mylibname, path_n); + else + _dl_strcpy(mylibname, "."); /* Assume current dir if empty path */ + _dl_strcat(mylibname, "/"); + _dl_strcat(mylibname, name); + if ((tpnt = _dl_load_elf_shared_library(secure, rpnt, mylibname)) != NULL) + return tpnt; + path_n = path+1; + } + path++; + } while (!done); return NULL; } -- cgit v1.2.3