Browse Source

dl-elf: Supress adding double '/' in library pathname

When searching for shared libraries, it could happen that redudant '/'
were added to the pathname with would later be reported via dladdr() in
the dli_fname member.

Signed-off-by: Daniel Dorau <d.dorau@avm.de>
Daniel Dorau 2 years ago
parent
commit
f372cab88d
1 changed files with 4 additions and 1 deletions
  1. 4 1
      ldso/ldso/dl-elf.c

+ 4 - 1
ldso/ldso/dl-elf.c

@@ -182,7 +182,10 @@ search_for_named_library(const char *name, unsigned int rflags, const char *path
 		} else {
 			_dl_strcpy(mylibname, ".");
 		}
-		_dl_strcat(mylibname, "/");
+		plen = _dl_strlen(mylibname);
+		if ((plen == 0) || (mylibname[plen-1] != '/')) {
+			_dl_strcat(mylibname, "/");
+		}
 		_dl_strcat(mylibname, name);
 #ifdef __LDSO_SAFE_RUNPATH__
 		if (*mylibname == '/')