summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2017-03-14 10:09:50 +0000
committerkib <kib@FreeBSD.org>2017-03-14 10:09:50 +0000
commitdcb5b4a5f51106cc7026c2812a0f94bc06f18b98 (patch)
tree2f7c286bb8bd305fe644acd438e2a787f243b761
parentd3dbc2dba2c5f2011fbf6ff98f6617135211f190 (diff)
downloadFreeBSD-src-dcb5b4a5f51106cc7026c2812a0f94bc06f18b98.zip
FreeBSD-src-dcb5b4a5f51106cc7026c2812a0f94bc06f18b98.tar.gz
MFC r314851:
When selecting brand based on old Elf branding, prefer the brand which interpreter exactly matches the one requested by the activated image.
-rw-r--r--sys/kern/imgact_elf.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c
index d1ac039..e6fe4b0 100644
--- a/sys/kern/imgact_elf.c
+++ b/sys/kern/imgact_elf.c
@@ -312,10 +312,23 @@ __elfN(get_brandinfo)(struct image_params *imgp, const char *interp,
strcmp((const char *)&hdr->e_ident[OLD_EI_BRAND],
bi->compat_3_brand) == 0)) {
/* Looks good, but give brand a chance to veto */
- if (!bi->header_supported || bi->header_supported(imgp))
- return (bi);
+ if (!bi->header_supported ||
+ bi->header_supported(imgp)) {
+ /*
+ * Again, prefer strictly matching
+ * interpreter path.
+ */
+ if (strlen(bi->interp_path) + 1 ==
+ interp_name_len && strncmp(interp,
+ bi->interp_path, interp_name_len) == 0)
+ return (bi);
+ if (bi_m == NULL)
+ bi_m = bi;
+ }
}
}
+ if (bi_m != NULL)
+ return (bi_m);
/* No known brand, see if the header is recognized by any brand */
for (i = 0; i < MAX_BRANDS; i++) {
OpenPOWER on IntegriCloud