summaryrefslogtreecommitdiffstats
path: root/main/musl/0007-explicitly-reject-empty-names-in-dynamic-linker-load.patch
blob: fe6fe31daf5313c81bf447ef43850dd73d226b57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
From 59549313d85fa9a0168ff8164cfe734255585f46 Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Fri, 11 Jul 2014 00:29:44 -0400
Subject: [PATCH] explicitly reject empty names in dynamic linker load_library
 function

previously passing an empty string for name resulted in failure, as
expected, but only after spurious syscalls, and it produced confusing
errno values (and thus dlerror strings).

in addition to dlopen calls, this issue affected use of LD_PRELOAD
with trailing whitespace or colon characters.
---
 src/ldso/dynlink.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c
index 6b7f0f3..12f14f7 100644
--- a/src/ldso/dynlink.c
+++ b/src/ldso/dynlink.c
@@ -663,6 +663,11 @@ static struct dso *load_library(const char *name, struct dso *needed_by)
 	int n_th = 0;
 	int is_self = 0;
 
+	if (!*name) {
+		errno = EINVAL;
+		return 0;
+	}
+
 	/* Catch and block attempts to reload the implementation itself */
 	if (name[0]=='l' && name[1]=='i' && name[2]=='b') {
 		static const char *rp, reserved[] =
-- 
2.0.2