# HG changeset patch # User Richard M. Stallman # Date 780117812 0 # Node ID 4dffbc5d5dc700750195d3fd39a21a5521f09b60 # Parent 390019f3ab08bdaf985e805f257ec7697af4ec97 (from, labels, data): Use MAX_DATA_LEN as length. (main): Use fgets, not gets. diff -r 390019f3ab08 -r 4dffbc5d5dc7 lib-src/b2m.c --- a/lib-src/b2m.c Wed Sep 21 00:59:22 1994 +0000 +++ b/lib-src/b2m.c Wed Sep 21 03:23:32 1994 +0000 @@ -15,9 +15,6 @@ * Mon Nov 7 15:54:06 PDT 1988 */ -/* Serious bug: This program uses `gets', which is intrinsically - unreliable--long lines will cause crashes. - Someone should fix this program not to use `gets'. */ #include #include #include @@ -37,9 +34,11 @@ #define FALSE (0) #endif +#define MAX_DATA_LEN 256 /* size for from[], labels[], and data[] arrays */ + int header = FALSE, printing; time_t ltoday; -char from[256], labels[256], data[256], *p, *today; +char from[MAX_DATA_LEN], labels[MAX_DATA_LEN], data[MAX_DATA_LEN], *p, *today; main (argc, argv) int argc; @@ -58,8 +57,7 @@ ltoday = time (0); today = ctime (<oday); - /* BUG! Must not use gets in a reliable program! */ - if (gets (data)) + if (fgets (data, MAX_DATA_LEN, stdin)) { if (strncmp (data, "BABYL OPTIONS:", 14)) { @@ -74,7 +72,7 @@ if (printing) puts (data); - while (gets (data)) + while (fgets (data, MAX_DATA_LEN, stdin)) { #if 0 @@ -94,7 +92,7 @@ if (!strcmp (data, "\037\f")) { /* save labels */ - gets (data); + fgets (data, MAX_DATA_LEN, stdin); p = strtok (data, " ,\r\n\t"); strcpy (labels, "X-Babyl-Labels: ");