| Summary: | banner seg faults on Ctrl-D | ||
|---|---|---|---|
| Product: | Base System | Reporter: | davidc <davidc> |
| Component: | bin | Assignee: | ru <ru> |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | ||
| Priority: | Normal | ||
| Version: | 5.0-CURRENT | ||
| Hardware: | Any | ||
| OS: | Any | ||
|
Description
davidc
2001-07-19 04:10:00 UTC
From: Chad David <davidc@acns.ab.ca> Subject: bin/29074: banner seg faults on Ctrl-D Date: Wed, Jul 18, 2001 at 09:03:56PM -0600 > >Description: > When banner is run without any arguments it displays a > Message: prompt. If Ctrl-D is entered at that point the > program core dumps. > > >How-To-Repeat: > Run banner without any arguments and press Ctrl-D at the > Message: prompt. > > >Fix: > Zero the buffer prior to calling fgets() or check the return > value of fgets(), the later is probably more correct. Try the following patch. It seems to solve problems on my banner. Index: banner.c =================================================================== RCS file: /home/ncvs/src/usr.bin/banner/banner.c,v retrieving revision 1.11 diff -u -r1.11 banner.c --- banner.c 2001/05/28 03:49:23 1.11 +++ banner.c 2001/07/19 03:21:08 @@ -1075,7 +1075,8 @@ if ((message = malloc((size_t)MAXMSG)) == NULL) err(1, "malloc"); fprintf(stderr,"Message: "); - (void)fgets(message, MAXMSG, stdin); + if (fgets(message, MAXMSG, stdin) == NULL) + exit(0); nchars = strlen(message); message[nchars--] = '\0'; /* get rid of newline */ } State Changed From-To: open->closed Fixed in 5.0-CURRENT, usr.bin/banner/banner.c,v 1.12. Responsible Changed From-To: freebsd-bugs->ru |