Subject: lib/11140: segmentation fault calling dlsym with null arg
To: None <gnats-bugs@gnats.netbsd.org>
From: None <takashi@plathome.co.jp>
List: netbsd-bugs
Date: 10/05/2000 00:42:33
>Number:         11140
>Category:       lib
>Synopsis:       segmentation fault calling dlsym with null arg
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Oct 05 00:42:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Takashi Hosokawa
>Release:        NetBSD 1.5_ALPHA2
>Organization:
PLAT'HOME CO.,LTD.
>Environment:
i386, NetBSD 1.5_ALPHA2, libc.so.12.62.1
>Description:
		When calling dlsym() with null symbol name, the program
		terminated with segmentation fault.
		for example,
			dlsym(handle, NULL);
		caused segmentation fault. Of cource, this is not a bug,
		but coding error. However, this is for reliablity of
		NetBSD.
>How-To-Repeat:
		At this moment I do not have sample coding.
		Because I found this problem during i18n enabled
		libX11.so which recentry SUN contributed.
>Fix:
	apply this patch for /usr/src/libexec/ld_elf.so/rtld.c
	may solve the problem.

*** rtld.c.orig	Tue Aug 29 10:47:42 2000
--- rtld.c	Tue Sep 19 02:59:10 2000
***************
*** 728,733 ****
--- 728,736 ----
  	const Elf_Sym *def;
  	const Obj_Entry *obj;
  
+ 	if (name == NULL || *name == '\0')
+ 		return NULL;
+ 
  	hash = _rtld_elf_hash(name);
  	obj = _rtld_objmain;
  
***************
*** 749,754 ****
--- 752,760 ----
  	const Elf_Sym *def;
  	const Obj_Entry *defobj;
  	
+ 	if (name == NULL || *name == '\0')
+ 		return NULL;
+ 
  	hash = _rtld_elf_hash(name);
  	def = NULL;
  	defobj = NULL;
>Release-Note:
>Audit-Trail:
>Unformatted: