From daver@gomerbud.com  Thu May 29 05:49:15 2003
Return-Path: <daver@gomerbud.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id D0BC237B401
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 29 May 2003 05:49:15 -0700 (PDT)
Received: from gold.he.net (gold.he.net [216.218.149.2])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 2C80E43FB1
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 29 May 2003 05:49:15 -0700 (PDT)
	(envelope-from daver@gomerbud.com)
Received: from tombstone.localnet.gomerbud.com (adsl-64-161-56-54.dsl.snlo01.pacbell.net [64.161.56.54]) by gold.he.net (8.8.6p2003-03-31/8.8.2) with ESMTP id FAA11997 for <FreeBSD-gnats-submit@freebsd.org>; Thu, 29 May 2003 05:49:13 -0700
Received: by tombstone.localnet.gomerbud.com (Postfix, from userid 1001)
	id EF66D395; Thu, 29 May 2003 05:49:13 -0700 (PDT)
Message-Id: <20030529124913.EF66D395@tombstone.localnet.gomerbud.com>
Date: Thu, 29 May 2003 05:49:13 -0700 (PDT)
From: "David P.Reese Jr." <daver@gomerbud.com>
Reply-To: "David P.Reese Jr." <daver@gomerbud.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] libmap.conf constraints are not parsed properly
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         52783
>Category:       bin
>Synopsis:       [PATCH] libmap.conf constraints are not parsed properly
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    mdodd
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu May 29 05:50:21 PDT 2003
>Closed-Date:    Thu May 29 17:50:04 PDT 2003
>Last-Modified:  Thu May 29 17:50:04 PDT 2003
>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@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:
Responsible-Changed-From-To: freebsd-bugs->mdodd 
Responsible-Changed-By: mbr 
Responsible-Changed-When: Thu May 29 14:52:15 PDT 2003 
Responsible-Changed-Why:  
Matthews work. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=52783 
State-Changed-From-To: open->closed 
State-Changed-By: mdodd 
State-Changed-When: Thu May 29 17:49:47 PDT 2003 
State-Changed-Why:  
Committed, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=52783 
>Unformatted:
