summaryrefslogtreecommitdiff
path: root/lib-src/b2m.c
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1994-09-21 03:23:32 +0000
committerRichard M. Stallman <rms@gnu.org>1994-09-21 03:23:32 +0000
commitfef5bc9413f17da9ab596456b6c31af3c57cf2dd (patch)
tree0cb53601122ee0b54b19ec563e97efc8978f7a11 /lib-src/b2m.c
parentc8f8fc5fab042496abd91175e610a8b960b282ba (diff)
downloademacs-fef5bc9413f17da9ab596456b6c31af3c57cf2dd.tar.gz
(from, labels, data): Use MAX_DATA_LEN as length.
(main): Use fgets, not gets.
Diffstat (limited to 'lib-src/b2m.c')
-rw-r--r--lib-src/b2m.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib-src/b2m.c b/lib-src/b2m.c
index 46485946c02..b6e027590a5 100644
--- a/lib-src/b2m.c
+++ b/lib-src/b2m.c
@@ -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 <stdio.h>
#include <time.h>
#include <sys/types.h>
@@ -37,9 +34,11 @@ extern char *strtok ();
#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 @@ main (argc, argv)
ltoday = time (0);
today = ctime (&ltoday);
- /* 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 @@ main (argc, argv)
if (printing)
puts (data);
- while (gets (data))
+ while (fgets (data, MAX_DATA_LEN, stdin))
{
#if 0
@@ -94,7 +92,7 @@ main (argc, argv)
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: ");