| Summary: | pccardd(8) Can Hang Reading Config File | ||
|---|---|---|---|
| Product: | Base System | Reporter: | cjclark <cjclark> |
| Component: | bin | Assignee: | freebsd-bugs (Nobody) <bugs> |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | ||
| Priority: | Normal | ||
| Version: | 4.2-STABLE | ||
| Hardware: | Any | ||
| OS: | Any | ||
State Changed From-To: open->closed 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 |
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. 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): (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.)--pqs94kcpAO4VrFCA3u1VAn7ssfO0Eudaf4wqb35gJEpH1Q2B Content-Type: text/plain; name="file.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="file.diff" 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); } How-To-Repeat: # echo -n "#No newline" >> /etc/pccard.conf # pccardd -f /etc/defaults/pccard.conf ^C #