summaryrefslogtreecommitdiff
path: root/base/echogs.c
diff options
context:
space:
mode:
authorChris Liddell <chris.liddell@artifex.com>2016-04-25 09:54:26 +0100
committerChris Liddell <chris.liddell@artifex.com>2016-04-25 13:19:34 +0100
commit43e5273d8ce5e8c7ec02da874129fd2bea26301e (patch)
treee9832decae9a333463187adaa9e20c6b8ad422de /base/echogs.c
parent3787c3f9753c542a5bd3f040b2aaa73db2f2f527 (diff)
downloadghostpdl-43e5273d8ce5e8c7ec02da874129fd2bea26301e.tar.gz
Coverity IDs 94494, 94617, 94818, 95043
94494: increase size of string buffer to allow for NULL termination. 94617: Initialize string pointer to avoid NULL dereference. 94818: Initialize string variable (fmode). 95043: Swtich to strncpy() to ensure we don't overflow string buffer
Diffstat (limited to 'base/echogs.c')
-rw-r--r--base/echogs.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/base/echogs.c b/base/echogs.c
index ec11c16d1..86e436d4f 100644
--- a/base/echogs.c
+++ b/base/echogs.c
@@ -92,7 +92,7 @@ main(int argc, char *argv[])
*/
FILE *in = 0;
const char *extn = "";
- char fmode[4];
+ char fmode[5] = {0};
#define FNSIZE 4096
char *fnparam = NULL; /* Initialisation to shut up compilers */
char fname[FNSIZE];
@@ -149,8 +149,10 @@ main(int argc, char *argv[])
argp[i] = argp[i - 1];
argp += 2, nargs -= 2;
}
- } else
+ } else {
strcpy(fname, "");
+ fnparam = fname; /* quieten static analysis */
+ }
if (nargs > 0 && !strcmp(*argp, "-h")) {
eputc = hputc, eputs = hputs;
argp++, nargs--;
@@ -235,7 +237,7 @@ main(int argc, char *argv[])
char str[26];
time(&t);
- strcpy(str, ctime(&t));
+ strncpy(str, ctime(&t), 25);
str[24] = 0; /* remove \n */
(*eputs) (str, out);
} break;