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.
This commit is contained in:
Bruce Evans 1995-09-29 18:44:53 +00:00
parent 6ef8b8ca0c
commit 89e45c9b7f
4 changed files with 13 additions and 6 deletions

View File

@ -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 */
}
}

View File

@ -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();

View File

@ -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);

View File

@ -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;
}