Thread View: net.bugs.usg
1 messages
1 total messages
Started by wescott
Tue, 09 Sep 1986 21:05
bug in newform
Author: wescott
Date: Tue, 09 Sep 1986 21:05
Date: Tue, 09 Sep 1986 21:05
73 lines
2362 bytes
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads