Browse Source

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.
Rich Felker 10 năm trước cách đây
mục cha
commit
59549313d8
1 tập tin đã thay đổi với 5 bổ sung0 xóa
  1. 5 0
      src/ldso/dynlink.c

+ 5 - 0
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 n_th = 0;
 	int is_self = 0;
 	int is_self = 0;
 
 
+	if (!*name) {
+		errno = EINVAL;
+		return 0;
+	}
+
 	/* Catch and block attempts to reload the implementation itself */
 	/* Catch and block attempts to reload the implementation itself */
 	if (name[0]=='l' && name[1]=='i' && name[2]=='b') {
 	if (name[0]=='l' && name[1]=='i' && name[2]=='b') {
 		static const char *rp, reserved[] =
 		static const char *rp, reserved[] =