Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F115848354
D34247.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D34247.diff
View Options
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -1175,10 +1175,22 @@
return (res);
}
+static const struct {
+ const char *kw;
+ bool pass_obj;
+ const char *subst;
+} tokens[] = {
+ { .kw = "$ORIGIN", .pass_obj = true, .subst = NULL },
+ { .kw = "$OSNAME", .pass_obj = false, .subst = uts.sysname },
+ { .kw = "$OSREL", .pass_obj = false, .subst = uts.release },
+ { .kw = "$PLATFORM", .pass_obj = false, .subst = uts.machine },
+};
+
static char *
origin_subst(Obj_Entry *obj, const char *real)
{
- char *res1, *res2, *res3, *res4;
+ char *res;
+ int i;
if (obj == NULL || !trust)
return (xstrdup(real));
@@ -1188,13 +1200,14 @@
return (NULL);
}
}
+
/* __DECONST is safe here since without may_free real is unchanged */
- res1 = origin_subst_one(obj, __DECONST(char *, real), "$ORIGIN", NULL,
- false);
- res2 = origin_subst_one(NULL, res1, "$OSNAME", uts.sysname, true);
- res3 = origin_subst_one(NULL, res2, "$OSREL", uts.release, true);
- res4 = origin_subst_one(NULL, res3, "$PLATFORM", uts.machine, true);
- return (res4);
+ res = __DECONST(char *, real);
+ for (i = 0; i < (int)nitems(tokens); i++) {
+ res = origin_subst_one(tokens[i].pass_obj ? obj : NULL,
+ res, tokens[i].kw, tokens[i].subst, i == 0);
+ }
+ return (res);
}
void
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Apr 30, 12:37 PM (10 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17857894
Default Alt Text
D34247.diff (1 KB)
Attached To
Mode
D34247: rtld: Add ${TOKEN} aliases to $TOKEN
Attached
Detach File
Event Timeline
Log In to Comment