From owner-freebsd-bugs Tue Mar 13 22:20: 8 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id CC99737B719 for ; Tue, 13 Mar 2001 22:20:01 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.1/8.11.1) id f2E6K1p49151; Tue, 13 Mar 2001 22:20:01 -0800 (PST) (envelope-from gnats) Received: from mailhost01.reflexnet.net (mailhost01.reflexnet.net [64.6.192.82]) by hub.freebsd.org (Postfix) with ESMTP id C645437B718 for ; 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 X-Send-Pr-Version: 3.2 Subject: bin/25791: pccardd(8) Can Hang Reading Config File Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >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