X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=cde%2Fprograms%2Fdtsr%2Ftomita.c;h=c165a365475bdbc38da0dcec8f2fdae271feddb9;hb=a1fb026d864e6f071c1b7a78968bc377fc5661fc;hp=d2db3027eae1c5564c17a037e2e0bf93f2b35adc;hpb=c884521619ded86baea5e0a74c8d0d2234c232fe;p=oweals%2Fcde.git diff --git a/cde/programs/dtsr/tomita.c b/cde/programs/dtsr/tomita.c index d2db3027..c165a365 100644 --- a/cde/programs/dtsr/tomita.c +++ b/cde/programs/dtsr/tomita.c @@ -89,6 +89,7 @@ #include #include #include +#include #define PRINT_MESSAGES \ { puts (DtSearchGetMessages()); DtSearchFreeMessages(); } @@ -196,7 +197,7 @@ static int change_database (char *newname) return FALSE; /* If browsing, tell user his options */ - fprintf (aa_stderr, catgets(dtsearch_catd, MS_tomita, 5, + fprintf (aa_stderr, "%s", catgets(dtsearch_catd, MS_tomita, 5, "Available choices are:") ); for (db = usrblk.dblist; db != NULL; db = db->link) fprintf (aa_stderr, " '%s'", db->name); @@ -246,7 +247,7 @@ static int parse_infbuf (char *infbuf) return FALSE; } - strcpy (parsed_dbname, ptr); + snprintf(parsed_dbname, sizeof(parsed_dbname), "%s", ptr); parsed_dblk = usrblk.dblk; /* Hop over to beginning of 2nd token */ @@ -422,7 +423,7 @@ static int browser (void) continue; default: - printf (catgets(dtsearch_catd, MS_tomita, 16, "...what?\n")); + printf ("%s", catgets(dtsearch_catd, MS_tomita, 16, "...what?\n")); continue; } /* end switch */ @@ -471,11 +472,14 @@ DISPLAY_RECORD: if (pausing && *ptr == '\n') { if (++pause_counter >= PAUSE_ROWS) { /* Msg 21 is used in two places */ - printf ( catgets(dtsearch_catd, MS_tomita, 21, + printf ( "%s", catgets(dtsearch_catd, MS_tomita, 21, "\n...push ENTER to continue... ") ); *userbuf = '\0'; - fgets (userbuf, sizeof (userbuf), stdin); + if(NULL == fgets (userbuf, sizeof (userbuf), stdin)) { + fprintf(stderr, "Failed to read from stdin\n"); + exit(EXIT_FAILURE); + } if (strlen(userbuf) && userbuf[strlen(userbuf)-1] == '\n') userbuf[strlen(userbuf)-1] = '\0'; @@ -500,12 +504,16 @@ DISPLAY_RECORD: if (pausing && *ptr == '\n') if (++pause_counter >= PAUSE_ROWS) { /* Msg 21 is used in two places */ - printf ( catgets(dtsearch_catd, MS_tomita, 21, + printf ( "%s", catgets(dtsearch_catd, MS_tomita, 21, "\n...push ENTER to continue... ") ); *userbuf = '\0'; - fgets (userbuf, sizeof (userbuf), stdin); - if (strlen(userbuf) && + if(NULL == fgets (userbuf, sizeof (userbuf), stdin)) { + fprintf(stderr, "Failed to read from stdin 2\n"); + exit(EXIT_FAILURE); + } + + if (strlen(userbuf) && userbuf[strlen(userbuf)-1] == '\n') userbuf[strlen(userbuf)-1] = '\0'; @@ -677,7 +685,10 @@ static void deleter (char *infname) "If you are sure you are ready to start deleting, enter 'y' now... ") , infname, OE_prodname); - fgets (buf, sizeof(buf)-1, stdin); + if(NULL == fgets (buf, sizeof(buf)-1, stdin)) { + fprintf(stderr, "no input\n"); + return; + } if (tolower (*buf) != 'y') return; } @@ -701,7 +712,9 @@ static void deleter (char *infname) signal (SIGQUIT, kill_delete); signal (SIGTRAP, kill_delete); signal (SIGTERM, kill_delete); +#ifdef SIGPWR signal (SIGPWR, kill_delete); +#endif #ifdef _AIX signal (SIGXCPU, kill_delete); /* cpu time limit exceeded */ signal (SIGDANGER, kill_delete); /* imminent paging space @@ -918,7 +931,7 @@ BAD_ARGS: usrblk.request = OE_SHUTDOWN; Opera_Engine (); - printf ( catgets(dtsearch_catd, MS_tomita, 36, + printf ( "%s", catgets(dtsearch_catd, MS_tomita, 36, "Normal engine shutdown.\n") ); DtSearchExit (0); } /* main() */