49 lines
1.5 KiB
Diff
49 lines
1.5 KiB
Diff
|
|
From 92faea67b31570e84b978a77b43c8f38bdad7bd4 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Sebastian Rasmussen <sebras@gmail.com>
|
||
|
|
Date: Tue, 1 Oct 2019 18:08:34 +0200
|
||
|
|
Subject: [PATCH] jbig2dec: Avoid warning by copying bytes instead of
|
||
|
|
characters.
|
||
|
|
|
||
|
|
---
|
||
|
|
jbig2dec/jbig2dec.c | 11 +++++++----
|
||
|
|
1 file changed, 7 insertions(+), 4 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/jbig2dec/jbig2dec.c b/jbig2dec/jbig2dec.c
|
||
|
|
index 39f487e..d7d0aef 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);
|
||
|
|
--
|
||
|
|
1.8.3.1
|
||
|
|
|