Subject: bin/1474: usr.bin/msgs spins on empty bounds file
To: None <gnats-bugs@gnats.netbsd.org>
From: Simon J. Gerraty <sjg@zen.void.oz.au>
List: netbsd-bugs
Date: 09/19/1995 08:45:55
>Number:         1474
>Category:       bin
>Synopsis:       msgs does not handle an empty bounds file.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Sep 18 18:50:01 1995
>Last-Modified:
>Originator:     Simon J. Gerraty
>Organization:
Zen Programming...
>Release:        95-08-18
>Environment:
	
System: NetBSD zen.void.oz.au 1.0A NetBSD 1.0A (ZEN) #0: Fri Aug 18 18:59:14 EST 1995 root@zen.void.oz.au:/f1/usr.src/sys/arch/i386/compile/ZEN i386


>Description:
	
msgs does not check the result of the fscanf done when reading the
bounds file.  On a Solaris machine this caused msgs to go into an
infinite loop, preventing anyone from logging in.

>How-To-Repeat:
	<code/input/activities to reproduce the problem (multiple
lines)>
	> /var/msgs/bounds
	msgs -fq &

>Fix:
	
*** msgs.c.~1~	Tue Apr 11 18:52:47 1995
--- msgs.c	Mon Sep 18 16:35:55 1995
***************
*** 242,248 ****
  	bounds = fopen(fname, "r");
  
  	if (bounds != NULL) {
! 		fscanf(bounds, "%d %d\n", &firstmsg, &lastmsg);
  		fclose(bounds);
  		blast = lastmsg;	/* save upper bound */
  	}
--- 247,254 ----
  	bounds = fopen(fname, "r");
  
  	if (bounds != NULL) {
! 		if (fscanf(bounds, "%d %d\n", &firstmsg, &lastmsg) < 2)
! 			firstmsg = lastmsg = 0;
  		fclose(bounds);
  		blast = lastmsg;	/* save upper bound */
  	}
>Audit-Trail:
>Unformatted: