From: Peter Howkins Date: Tue, 24 Apr 2018 02:03:06 +0000 (+0100) Subject: dtsr: Coverity fixes for string buffer issues X-Git-Tag: 2.2.4a~65 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a1fb026d864e6f071c1b7a78968bc377fc5661fc;p=oweals%2Fcde.git dtsr: Coverity fixes for string buffer issues --- diff --git a/cde/programs/dtsr/dtsrclean.c b/cde/programs/dtsr/dtsrclean.c index b5ab2bae..8c2d8814 100644 --- a/cde/programs/dtsr/dtsrclean.c +++ b/cde/programs/dtsr/dtsrclean.c @@ -1044,7 +1044,7 @@ int main (int argc, char *argv[]) fprintf (aa_stderr, catgets(dtsearch_catd, MS_dtsrclean, 13, "%s: Using DBFPATH = '%s'.\n") , aa_argv0, ptr); - strcpy (full_dbname_old, ptr); + snprintf(full_dbname_old, sizeof(full_dbname_old), "%s", ptr); /* Ensure that DBFPATH ends in a slash. */ ptr = strchr (full_dbname_old, '\0'); diff --git a/cde/programs/dtsr/dtsrdbrec.c b/cde/programs/dtsr/dtsrdbrec.c index 800c7e5b..cbc9b56d 100644 --- a/cde/programs/dtsr/dtsrdbrec.c +++ b/cde/programs/dtsr/dtsrdbrec.c @@ -319,7 +319,7 @@ int main (int argc, char *argv[]) "USAGE: %s \n"), aa_argv0); return 2; } - sprintf (renamebuf, "%s.d00", argv[1]); + snprintf(renamebuf, sizeof(renamebuf), "%s.d00", argv[1]); db_oflag = O_RDONLY; /* db files may be read-only */ d_open (argv[1], "o"); if (db_status != S_OKAY) { diff --git a/cde/programs/dtsr/dtsrhan.c b/cde/programs/dtsr/dtsrhan.c index fdf8b64e..acac00db 100644 --- a/cde/programs/dtsr/dtsrhan.c +++ b/cde/programs/dtsr/dtsrhan.c @@ -795,7 +795,7 @@ void process_profile () bad_profile = TRUE; continue; } - strcpy (field_current->text, tok); + snprintf(field_current->text, sizeof(field_current->text), "%s", tok); field_current->text_length = strlen (field_current->text); /*-- get offset --*/ diff --git a/cde/programs/dtsr/huffcode.c b/cde/programs/dtsr/huffcode.c index c5f3b710..947dfb0f 100644 --- a/cde/programs/dtsr/huffcode.c +++ b/cde/programs/dtsr/huffcode.c @@ -387,11 +387,11 @@ static char *char_label (int x) if (x > 256) return ""; else if (x < 32) { - sprintf (buf, "'CTRL-%c'", 0x40 | x); + snprintf(buf, sizeof(buf), "'CTRL-%c'", 0x40 | x); return buf; } else if (x >= 128) { - strcpy (buf, catgets(dtsearch_catd, MS_huff, 32, + snprintf(buf, sizeof(buf), "%s", catgets(dtsearch_catd, MS_huff, 32, "(nonascii char, high bit set)")); return buf; } diff --git a/cde/programs/dtsr/tomita.c b/cde/programs/dtsr/tomita.c index 92076405..c165a365 100644 --- a/cde/programs/dtsr/tomita.c +++ b/cde/programs/dtsr/tomita.c @@ -247,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 */