From 416532309a9e41611ce720ed3e292f6caa4bd445 Mon Sep 17 00:00:00 2001 From: bde Date: Fri, 29 Sep 1995 18:44:53 +0000 Subject: Don't use gets(). sys_curses/system.c: Don't use gets() better. Neither gets() nor fgets() is appropriate for discarding a line of input. --- usr.bin/tn3270/ctlr/api.c | 7 ++++++- usr.bin/tn3270/distribution/sys_dos/system.c | 5 +++-- usr.bin/tn3270/sys_curses/system.c | 5 +++-- usr.bin/tn3270/tools/mkhits/dohits.c | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) (limited to 'usr.bin/tn3270') diff --git a/usr.bin/tn3270/ctlr/api.c b/usr.bin/tn3270/ctlr/api.c index 8a9ea3e..801e0ee 100644 --- a/usr.bin/tn3270/ctlr/api.c +++ b/usr.bin/tn3270/ctlr/api.c @@ -749,7 +749,12 @@ struct SREGS *sregs; Dump('>', (char *)regs, sizeof *regs); Dump('>', (char *)sregs, sizeof *sregs); #ifdef MSDOS - { char buf[10]; gets(buf); } + { + int ch; + + while ((ch = getchar()) != '\n' && ch != EOF) + ; + } #endif /* MSDOS */ } } diff --git a/usr.bin/tn3270/distribution/sys_dos/system.c b/usr.bin/tn3270/distribution/sys_dos/system.c index 864926b..06c2194 100644 --- a/usr.bin/tn3270/distribution/sys_dos/system.c +++ b/usr.bin/tn3270/distribution/sys_dos/system.c @@ -74,7 +74,7 @@ shell_continue() handle_api(&spinted.regs, &spinted.sregs); spint_continue(&spinted); } else { - char inputbuffer[100]; + int ch; if (spinted.rc != 0) { fprintf(stderr, "Process generated a return code of 0x%x.\n", @@ -82,7 +82,8 @@ shell_continue() } printf("[Hit return to continue]"); fflush(stdout); - (void) gets(inputbuffer); + while ((ch = getchar()) != '\n' && ch != EOF) + ; shell_active = 0; setconnmode(); ConnectScreen(); diff --git a/usr.bin/tn3270/sys_curses/system.c b/usr.bin/tn3270/sys_curses/system.c index 9e1be33..67b31af 100644 --- a/usr.bin/tn3270/sys_curses/system.c +++ b/usr.bin/tn3270/sys_curses/system.c @@ -593,7 +593,7 @@ child_died(code) while ((pid = wait3((int *)&status, WNOHANG, (struct rusage *)0)) > 0) { if (pid == shell_pid) { - char inputbuffer[100]; + int ch; extern void setconnmode(); extern void ConnectScreen(); @@ -604,7 +604,8 @@ child_died(code) } printf("[Hit return to continue]"); fflush(stdout); - (void) fgets(inputbuffer, sizeof(inputbuffer), stdin); + while ((ch = getchar()) != '\n' && ch != EOF) + ; setconnmode(); ConnectScreen(); /* Turn screen on (if need be) */ (void) close(serversock); diff --git a/usr.bin/tn3270/tools/mkhits/dohits.c b/usr.bin/tn3270/tools/mkhits/dohits.c index d2d576e..afa36af 100644 --- a/usr.bin/tn3270/tools/mkhits/dohits.c +++ b/usr.bin/tn3270/tools/mkhits/dohits.c @@ -257,7 +257,7 @@ char *aidfile, *fcnfile; } scanwhite(fcnfile, "FCN_"); - while (gets(line) != NULL) { + while (fgets(line, sizeof line, stdin) != NULL) { if (!isdigit(line[0])) { continue; } -- cgit v1.1