diff options
| author | Richard M. Stallman | 1994-09-21 03:23:32 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-09-21 03:23:32 +0000 |
| commit | 128ba46c137ef367aaaccde955c38c7d96630abd (patch) | |
| tree | f516c9c7e0ace58874f61e64edc3fd516ee9065d /lib-src | |
| parent | 8eca17c9a5ed835fa1605bf49d83b476a40f161a (diff) | |
| download | emacs-128ba46c137ef367aaaccde955c38c7d96630abd.tar.gz emacs-128ba46c137ef367aaaccde955c38c7d96630abd.zip | |
(from, labels, data): Use MAX_DATA_LEN as length.
(main): Use fgets, not gets.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/b2m.c | 14 |
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 @@ | |||
| 15 | * Mon Nov 7 15:54:06 PDT 1988 | 15 | * Mon Nov 7 15:54:06 PDT 1988 |
| 16 | */ | 16 | */ |
| 17 | 17 | ||
| 18 | /* Serious bug: This program uses `gets', which is intrinsically | ||
| 19 | unreliable--long lines will cause crashes. | ||
| 20 | Someone should fix this program not to use `gets'. */ | ||
| 21 | #include <stdio.h> | 18 | #include <stdio.h> |
| 22 | #include <time.h> | 19 | #include <time.h> |
| 23 | #include <sys/types.h> | 20 | #include <sys/types.h> |
| @@ -37,9 +34,11 @@ extern char *strtok (); | |||
| 37 | #define FALSE (0) | 34 | #define FALSE (0) |
| 38 | #endif | 35 | #endif |
| 39 | 36 | ||
| 37 | #define MAX_DATA_LEN 256 /* size for from[], labels[], and data[] arrays */ | ||
| 38 | |||
| 40 | int header = FALSE, printing; | 39 | int header = FALSE, printing; |
| 41 | time_t ltoday; | 40 | time_t ltoday; |
| 42 | char from[256], labels[256], data[256], *p, *today; | 41 | char from[MAX_DATA_LEN], labels[MAX_DATA_LEN], data[MAX_DATA_LEN], *p, *today; |
| 43 | 42 | ||
| 44 | main (argc, argv) | 43 | main (argc, argv) |
| 45 | int argc; | 44 | int argc; |
| @@ -58,8 +57,7 @@ main (argc, argv) | |||
| 58 | ltoday = time (0); | 57 | ltoday = time (0); |
| 59 | today = ctime (<oday); | 58 | today = ctime (<oday); |
| 60 | 59 | ||
| 61 | /* BUG! Must not use gets in a reliable program! */ | 60 | if (fgets (data, MAX_DATA_LEN, stdin)) |
| 62 | if (gets (data)) | ||
| 63 | { | 61 | { |
| 64 | if (strncmp (data, "BABYL OPTIONS:", 14)) | 62 | if (strncmp (data, "BABYL OPTIONS:", 14)) |
| 65 | { | 63 | { |
| @@ -74,7 +72,7 @@ main (argc, argv) | |||
| 74 | if (printing) | 72 | if (printing) |
| 75 | puts (data); | 73 | puts (data); |
| 76 | 74 | ||
| 77 | while (gets (data)) | 75 | while (fgets (data, MAX_DATA_LEN, stdin)) |
| 78 | { | 76 | { |
| 79 | 77 | ||
| 80 | #if 0 | 78 | #if 0 |
| @@ -94,7 +92,7 @@ main (argc, argv) | |||
| 94 | if (!strcmp (data, "\037\f")) | 92 | if (!strcmp (data, "\037\f")) |
| 95 | { | 93 | { |
| 96 | /* save labels */ | 94 | /* save labels */ |
| 97 | gets (data); | 95 | fgets (data, MAX_DATA_LEN, stdin); |
| 98 | p = strtok (data, " ,\r\n\t"); | 96 | p = strtok (data, " ,\r\n\t"); |
| 99 | strcpy (labels, "X-Babyl-Labels: "); | 97 | strcpy (labels, "X-Babyl-Labels: "); |
| 100 | 98 | ||