From eae79da24b5629509e88ccb82249b63254fdcc3e Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Wed, 30 May 2001 21:45:50 +0000 Subject: [PATCH] From the PR: 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. This fix, provided by the PR, will allow files ending without a newline to be read without hanging. Submitted by: Crist J. Clark PR: bin/25791 --- usr.sbin/pccard/pccardd/file.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/usr.sbin/pccard/pccardd/file.c b/usr.sbin/pccard/pccardd/file.c index ec3010cd71ba..0bfcc0b8489f 100644 --- a/usr.sbin/pccard/pccardd/file.c +++ b/usr.sbin/pccard/pccardd/file.c @@ -836,10 +836,8 @@ get(void) } 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); }