diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2019-10-01 18:08:34 +0200 |
---|---|---|
committer | Sebastian Rasmussen <sebras@gmail.com> | 2020-03-20 17:56:08 +0800 |
commit | 92faea67b31570e84b978a77b43c8f38bdad7bd4 (patch) | |
tree | 5ff3f75294aa761ae61312a77bb14db58dc038bf /jbig2dec | |
parent | f20fc43d80e31780935be96393800cc1fac8ac50 (diff) | |
download | ghostpdl-92faea67b31570e84b978a77b43c8f38bdad7bd4.tar.gz |
jbig2dec: Avoid warning by copying bytes instead of characters.
Diffstat (limited to 'jbig2dec')
-rw-r--r-- | jbig2dec/jbig2dec.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/jbig2dec/jbig2dec.c b/jbig2dec/jbig2dec.c index 39f487ebb..d7d0aef6d 100644 --- a/jbig2dec/jbig2dec.c +++ b/jbig2dec/jbig2dec.c @@ -458,6 +458,7 @@ make_output_filename(const char *input_filename, const char *extension) { char *output_filename; const char *c, *e; + int extlen; int len; if (extension == NULL) { @@ -488,16 +489,18 @@ make_output_filename(const char *input_filename, const char *extension) if (e != NULL) len -= strlen(e); + extlen = strlen(extension); + /* allocate enough space for the base + ext */ - output_filename = (char *)malloc(len + strlen(extension) + 1); + output_filename = (char *)malloc(len + extlen + 1); if (output_filename == NULL) { fprintf(stderr, "failed to allocate memory for output filename\n"); exit(1); } - strncpy(output_filename, c, len); - strncpy(output_filename + len, extension, strlen(extension)); - *(output_filename + len + strlen(extension)) = '\0'; + memcpy(output_filename, c, len); + memcpy(output_filename + len, extension, extlen); + *(output_filename + len + extlen) = '\0'; /* return the new string */ return (output_filename); |