bin/52783: [PATCH] libmap.conf constraints are not parsed properly

David P.Reese Jr. daver at gomerbud.com
Thu May 29 05:50:23 PDT 2003


>Number:         52783
>Category:       bin
>Synopsis:       [PATCH] libmap.conf constraints are not parsed properly
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu May 29 05:50:21 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator:     David P. Reese Jr.
>Release:        FreeBSD 5.1-BETA i386
>Organization:
>Environment:
System: FreeBSD tombstone.localnet.gomerbud.com 5.1-BETA FreeBSD 5.1-BETA #16: Tue May 27 23:53:27 PDT 2003 root at tombstone.localnet.gomerbud.com:/tmp/obj/usr/src/sys/TOMBSTONE i386


	rtld-elf built with -DWITH_LIBMAP
>Description:
	When libmap.conf is parsed and a constraint is encountered, it is
	possible for the parser to fail.

	The parsing routine is contained in libmap.c:lm_init().  The parser uses
	the character pointer cp to walk each line in the config file.  After
	encountering a ']', the character is nulled and cp is incremented.
	The following characters are then walked using isspace() in a while
	loop.  If non whitespace is encountered, the while loop incorrectly
	increments cp past that character before iseol() is called.

>How-To-Repeat:
	Change the #if 0 on line 170 of libmap.conf to an #if 1 to watch
	the debugging output.  Build rtld-elf with -DWITH_LIBMAP and run
	any dynamically linked binary using the following /etc/libmap.conf:

libc_r.so.5                libc_r.so.5
libc_r.so                  libc_r.so

[/usr/local/bin/mplayer]
libc_r.so.5                libc_r.so.5
libc_r.so                  libc_r.so
[mplayer]
libc_r.so.5                libc_r.so.5
libc_r.so                  libc_r.so

[/usr/X11R6/bin/xine]
libc_r.so.5                libc_r.so.5
libc_r.so                  libc_r.so
[xine]
libc_r.so.5                libc_r.so.5
libc_r.so                  libc_r.so

	The debugging output should look something like:

lm_add("$DEFAULT$", "libc_r.so.5", "libc_r.so.5")
lm_add("$DEFAULT$", "libc_r.so", "libc_r.so")
lm_add("ibc_r.so.5", "libc_r.so.5", "libc_r.so.5")
lm_add("ibc_r.so", "libc_r.so", "libc_r.so")
lm_add("mplayer", "libc_r.so.5", "libc_r.so.5")
lm_add("mplayer", "libc_r.so", "libc_r.so")
lm_add("ibc_r.so.5", "libc_r.so.5", "libc_r.so.5")
lm_add("ibc_r.so", "libc_r.so", "libc_r.so")
lm_add("ibc_r.so.5", "libc_r.so.5", "libc_r.so.5")
lm_add("ibc_r.so", "libc_r.so", "libc_r.so")

>Fix:

--- libmap.diff begins here ---
Index: libmap.c
===================================================================
RCS file: /home/daver/cvs-freebsd/src/libexec/rtld-elf/libmap.c,v
retrieving revision 1.4
diff -u -r1.4 libmap.c
--- libmap.c	19 May 2003 07:10:12 -0000	1.4
+++ libmap.c	29 May 2003 12:26:03 -0000
@@ -93,7 +93,7 @@
 			 * There should be nothing except whitespace or comment
 			 * from this point to the end of the line.   
 			 */
-			while(isspace(*cp++));
+			while(isspace(*cp)) *cp++;
 			if (!iseol(*cp)) continue;
 
 			strcpy(prog, p);
--- libmap.diff ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list