🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.bugs.usg
Article #337

bug in newform

#337
From: wescott
Date: Tue, 09 Sep 1986 21:05
73 lines
2362 bytes
The newform(1) program gracelessly dumps core if you feed it a long
enough line.  Patch is below.  The fix truncates input at NCOLS (512)
characters.

Your line numbers will differ:

*** newform.c.orig	Tue Sep  9 14:10:18 1986
--- newform.c	Tue Sep  9 16:58:42 1986
***************
*** 558,563
  	char	*xarea,		/* Temporary pointer to character array	*/
  		UNDEF = '\377',		/* Undefined char for return */
  		*temp;		/* Array pointer			*/
  
  	xarea = area;
  	if (kludge && (fp == stdin)) {

--- 559,566 -----
  	char	*xarea,		/* Temporary pointer to character array	*/
  		UNDEF = '\377',		/* Undefined char for return */
  		*temp;		/* Array pointer			*/
+ 	int	cnt = NCOLS;	/* Count chars read in 			*/
+ 	int	errflg = 0;	/* Line too long aleady been said	*/
  
  	xarea = area;
  	if (kludge && (fp == stdin)) {
***************
*** 567,573
  		return(xarea);
  		}
  	else {
! 		while ((*area++ = c = getc(fp)) != '\n' && c != EOF) ;
  		if (c == EOF) {
  			if (--area == xarea)return(NULL);
  			else {

--- 570,584 -----
  		return(xarea);
  		}
  	else {
! 		while ((*area++ = c = getc(fp)) != '\n' && c != EOF)
! 			if (cnt-- <= 0) {
! 				area--;
! 				if (!errflg) {
! 					fprintf(stderr,
! 						"newform: input line too long, truncated\n");
! 					errflg++;
! 				}
! 			}
  		if (c == EOF) {
  			if (--area == xarea)return(NULL);
  			else {
***************
*** 576,582
  				}
  			}
  		}
! return(&UNDEF);	/* Stops 'lint's complaint about return(e) VS return. */
  }
  /* _________________________________________________________________ */
  

--- 587,593 -----
  				}
  			}
  		}
! 	return(xarea);
  }
  /* _________________________________________________________________ */
  
-- 
	-Mike Wescott
	 ncrcae!wescott
Technical Details
Message-ID: <721@sauron.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!lll-crg!topaz!husc6!panda!genrad!decvax!decwrl!pyramid!gould9!ncr-sd!ncrcae!sauron!wescott

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!lll-crg!topaz!husc6!panda!genrad!decvax!decwrl!pyramid!gould9!ncr-sd!ncrcae!sauron!wescott
From: wescott@sauron.UUCP
Newsgroups: net.bugs.usg
Subject: bug in newform
Message-ID: <721@sauron.UUCP>
Date: Tue, 9-Sep-86 17:05:42 EDT
Article-I.D.: sauron.721
Posted: Tue Sep  9 17:05:42 1986
Date-Received: Wed, 10-Sep-86 20:20:45 EDT
Reply-To: wescott@sauron.UUCP (Mike Wescott)
Organization: NCR Corp., Advanced System Development, Columbia, SC
Lines: 73