From davidc@colnta.acns.ab.ca  Wed Jul 18 20:04:01 2001
Return-Path: <davidc@colnta.acns.ab.ca>
Received: from colnta.acns.ab.ca (h24-68-206-125.sbm.shawcable.net [24.68.206.125])
	by hub.freebsd.org (Postfix) with ESMTP id 867B437B405
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 18 Jul 2001 20:04:00 -0700 (PDT)
	(envelope-from davidc@colnta.acns.ab.ca)
Received: (from davidc@localhost)
	by colnta.acns.ab.ca (8.11.4/8.11.3) id f6J33uY71742;
	Wed, 18 Jul 2001 21:03:56 -0600 (MDT)
	(envelope-from davidc)
Message-Id: <200107190303.f6J33uY71742@colnta.acns.ab.ca>
Date: Wed, 18 Jul 2001 21:03:56 -0600 (MDT)
From: Chad David <davidc@acns.ab.ca>
Reply-To: Chad David <davidc@acns.ab.ca>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: banner seg faults on Ctrl-D
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         29074
>Category:       bin
>Synopsis:       banner seg faults on Ctrl-D
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    ru
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jul 18 20:10:00 PDT 2001
>Closed-Date:    Thu Jul 19 01:06:08 PDT 2001
>Last-Modified:  Thu Jul 19 01:07:55 PDT 2001
>Originator:     Chad David
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
ACNS Inc.
>Environment:
System: FreeBSD snoop.acns.ab.ca 5.0-CURRENT FreeBSD 5.0-CURRENT #1: Wed Jun 18 19:28:31 MDT 2001 root@snoop.acns.ab.ca:/usr/src/sys/i386/compile/GENERIC i386


	
>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.
>Release-Note:
>Audit-Trail:

From: Giorgos Keramidas <keramida@ceid.upatras.gr>
To: Chad David <davidc@acns.ab.ca>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/29074: banner seg faults on Ctrl-D
Date: Thu, 19 Jul 2001 06:23:27 +0300

 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 
State-Changed-By: ru 
State-Changed-When: Thu Jul 19 01:06:08 PDT 2001 
State-Changed-Why:  
Fixed in 5.0-CURRENT, usr.bin/banner/banner.c,v 1.12. 


Responsible-Changed-From-To: freebsd-bugs->ru 
Responsible-Changed-By: ru 
Responsible-Changed-When: Thu Jul 19 01:06:08 PDT 2001 
Responsible-Changed-Why:  

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=29074 
>Unformatted:
