Skip to content

Commit 1b92c75

Browse files
committed
rtld c18n: Use basename of pathnames for compartment names
For object files without DT_SONAME or other names which fallback to obj->path, trim the path to the basename to set the compartment name.
1 parent 367ad92 commit 1b92c75

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

libexec/rtld-elf/rtld.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -6417,9 +6417,11 @@ c18n_add_obj(Obj_Entry *obj, int flags)
64176417
name = obj->soname;
64186418
else if (!STAILQ_EMPTY(&obj->names))
64196419
name = STAILQ_FIRST(&obj->names)->name;
6420-
else if (obj->path != NULL)
6421-
name = obj->path;
6422-
else {
6420+
else if (obj->path != NULL) {
6421+
name = strrchr(obj->path, '/');
6422+
if (name == NULL || name[1] == '\0')
6423+
name = obj->path;
6424+
} else {
64236425
_rtld_error("Shared object at %#p cannot be named",
64246426
obj->mapbase);
64256427
return (false);

0 commit comments

Comments
 (0)