From cjc@rfx-216-196-73-168.users.reflexcom.com  Tue Mar 13 22:17:14 2001
Return-Path: <cjc@rfx-216-196-73-168.users.reflexcom.com>
Received: from mailhost01.reflexnet.net (mailhost01.reflexnet.net [64.6.192.82])
	by hub.freebsd.org (Postfix) with ESMTP id C645437B718
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 13 Mar 2001 22:17:14 -0800 (PST)
	(envelope-from cjc@rfx-216-196-73-168.users.reflexcom.com)
Received: from rfx-216-196-73-168.users.reflexcom.com ([216.196.73.168]) by mailhost01.reflexnet.net  with Microsoft SMTPSVC(5.5.1877.197.19);
	 Tue, 13 Mar 2001 22:15:06 -0800
Received: (from cjc@localhost)
	by rfx-216-196-73-168.users.reflexcom.com (8.11.1/8.11.1) id f2E6H2i10554;
	Tue, 13 Mar 2001 22:17:02 -0800 (PST)
	(envelope-from cjc)
Message-Id: <200103140617.f2E6H2i10554@rfx-216-196-73-168.users.reflexcom.com>
Date: Tue, 13 Mar 2001 22:17:02 -0800 (PST)
From: cjclark@reflexnet.net
Reply-To: cjclark@alum.mit.edu
To: FreeBSD-gnats-submit@freebsd.org
Subject: pccardd(8) Can Hang Reading Config File
X-Send-Pr-Version: 3.2

>Number:         25791
>Category:       bin
>Synopsis:       pccardd(8) Can Hang Reading Config File
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Mar 13 22:20:01 PST 2001
>Closed-Date:    Wed May 30 15:45:57 MDT 2001
>Last-Modified:  Wed May 30 15:46:23 MDT 2001
>Originator:     Crist J. Clark
>Release:        FreeBSD 4.2-STABLE i386
>Organization:
>Environment:

	Both -CURRENT and -STABLE systems.

>Description:

	The PCCard daemon can hang indefinately while reading its
configuration file. If the last line of the file is a comment line
that does not end in a newline, the program goes into an infinite
loop searching for the non-existent newline.

>How-To-Repeat:

	# echo -n "#No newline" >> /etc/pccard.conf
        # pccardd -f /etc/defaults/pccard.conf
	^C
	#

>Fix:

	The configuration file parsing code for this program, file.c,
seems much, much, much more complex and convoluted than need be (it
does its own strtol(3)?). However, this particular little glitch can
be fixed with a very simple patch (this is against -CURRENT, but
file.c is identical in the branches):

Index: file.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pccard/pccardd/file.c,v
retrieving revision 1.24.2.4
diff -u -r1.24.2.4 file.c
--- file.c      2000/07/18 04:59:39     1.24.2.4
+++ file.c      2001/03/14 06:12:56
@@ -836,10 +836,8 @@
        }
        if (c == '\n')
                lineno++;
-       if (c == '#') {
-               while (get() != '\n');
-               return (last_char = '\n');
-       }
+       if (c == '#')
+               while (((c = get()) != '\n') && (c != EOF));
        return (last_char = c);
 }

(Note: I hope this is not a repeat. I sent a PR last night when I did
this, but it does not appear to have gotten through.)
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: imp 
State-Changed-When: Wed May 30 15:45:57 MDT 2001 
State-Changed-Why:  
Fixed: 
Checking in file.c; 
/home/imp/FreeBSD/CVS/src/usr.sbin/pccard/pccardd/file.c,v  <--  file.c 
new revision: 1.32; previous revision: 1.31 
done 


http://www.FreeBSD.org/cgi/query-pr.cgi?pr=25791 
>Unformatted:
