Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 Mar 2001 22:17:02 -0800 (PST)
From:      cjclark@reflexnet.net
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/25791: pccardd(8) Can Hang Reading Config File
Message-ID:  <200103140617.f2E6H2i10554@rfx-216-196-73-168.users.reflexcom.com>

next in thread | raw e-mail | index | archive | help

>Number:         25791
>Category:       bin
>Synopsis:       pccardd(8) Can Hang Reading Config File
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Mar 13 22:20:01 PST 2001
>Closed-Date:
>Last-Modified:
>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:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200103140617.f2E6H2i10554>