|
|
623fdc |
From 06d1b08aef94984256cad3c5a54cedb10295681f Mon Sep 17 00:00:00 2001
|
|
|
623fdc |
From: Jakub Martisko <jamartis@redhat.com>
|
|
|
623fdc |
Date: Thu, 8 Nov 2018 09:31:18 +0100
|
|
|
623fdc |
Subject: [PATCH] Possible unterminated string fix
|
|
|
623fdc |
|
|
|
623fdc |
---
|
|
|
623fdc |
unix/unix.c | 4 +++-
|
|
|
623fdc |
unix/unxcfg.h | 2 +-
|
|
|
623fdc |
unzip.c | 12 ++++++++----
|
|
|
623fdc |
zipinfo.c | 12 ++++++++----
|
|
|
623fdc |
4 files changed, 20 insertions(+), 10 deletions(-)
|
|
|
623fdc |
|
|
|
623fdc |
diff --git a/unix/unix.c b/unix/unix.c
|
|
|
623fdc |
index 59b622d..cd57f80 100644
|
|
|
623fdc |
--- a/unix/unix.c
|
|
|
623fdc |
+++ b/unix/unix.c
|
|
|
623fdc |
@@ -1945,7 +1945,9 @@ void init_conversion_charsets()
|
|
|
623fdc |
for(i = 0; i < sizeof(dos_charset_map)/sizeof(CHARSET_MAP); i++)
|
|
|
623fdc |
if(!strcasecmp(local_charset, dos_charset_map[i].local_charset)) {
|
|
|
623fdc |
strncpy(OEM_CP, dos_charset_map[i].archive_charset,
|
|
|
623fdc |
- sizeof(OEM_CP));
|
|
|
623fdc |
+ MAX_CP_NAME - 1);
|
|
|
623fdc |
+
|
|
|
623fdc |
+ OEM_CP[MAX_CP_NAME - 1] = '\0';
|
|
|
623fdc |
break;
|
|
|
623fdc |
}
|
|
|
623fdc |
}
|
|
|
623fdc |
diff --git a/unix/unxcfg.h b/unix/unxcfg.h
|
|
|
623fdc |
index 8729de2..9ee8cfe 100644
|
|
|
623fdc |
--- a/unix/unxcfg.h
|
|
|
623fdc |
+++ b/unix/unxcfg.h
|
|
|
623fdc |
@@ -228,7 +228,7 @@ typedef struct stat z_stat;
|
|
|
623fdc |
/* and notfirstcall are used by do_wild(). */
|
|
|
623fdc |
|
|
|
623fdc |
|
|
|
623fdc |
-#define MAX_CP_NAME 25
|
|
|
623fdc |
+#define MAX_CP_NAME 25 + 1
|
|
|
623fdc |
|
|
|
623fdc |
#ifdef SETLOCALE
|
|
|
623fdc |
# undef SETLOCALE
|
|
|
623fdc |
diff --git a/unzip.c b/unzip.c
|
|
|
623fdc |
index 2d94a38..a485f2b 100644
|
|
|
623fdc |
--- a/unzip.c
|
|
|
623fdc |
+++ b/unzip.c
|
|
|
623fdc |
@@ -1561,7 +1561,8 @@ int uz_opts(__G__ pargc, pargv)
|
|
|
623fdc |
"error: a valid character encoding should follow the -I argument"));
|
|
|
623fdc |
return(PK_PARAM);
|
|
|
623fdc |
}
|
|
|
623fdc |
- strncpy(ISO_CP, s, sizeof(ISO_CP));
|
|
|
623fdc |
+ strncpy(ISO_CP, s, MAX_CP_NAME - 1);
|
|
|
623fdc |
+ ISO_CP[MAX_CP_NAME - 1] = '\0';
|
|
|
623fdc |
} else { /* -I charset */
|
|
|
623fdc |
++argv;
|
|
|
623fdc |
if(!(--argc > 0 && *argv != NULL && **argv != '-')) {
|
|
|
623fdc |
@@ -1570,7 +1571,8 @@ int uz_opts(__G__ pargc, pargv)
|
|
|
623fdc |
return(PK_PARAM);
|
|
|
623fdc |
}
|
|
|
623fdc |
s = *argv;
|
|
|
623fdc |
- strncpy(ISO_CP, s, sizeof(ISO_CP));
|
|
|
623fdc |
+ strncpy(ISO_CP, s, MAX_CP_NAME - 1);
|
|
|
623fdc |
+ ISO_CP[MAX_CP_NAME - 1] = '\0';
|
|
|
623fdc |
}
|
|
|
623fdc |
while(*(++s)); /* No params straight after charset name */
|
|
|
623fdc |
}
|
|
|
623fdc |
@@ -1665,7 +1667,8 @@ int uz_opts(__G__ pargc, pargv)
|
|
|
623fdc |
"error: a valid character encoding should follow the -I argument"));
|
|
|
623fdc |
return(PK_PARAM);
|
|
|
623fdc |
}
|
|
|
623fdc |
- strncpy(OEM_CP, s, sizeof(OEM_CP));
|
|
|
623fdc |
+ strncpy(OEM_CP, s, MAX_CP_NAME - 1);
|
|
|
623fdc |
+ OEM_CP[MAX_CP_NAME - 1] = '\0';
|
|
|
623fdc |
} else { /* -O charset */
|
|
|
623fdc |
++argv;
|
|
|
623fdc |
if(!(--argc > 0 && *argv != NULL && **argv != '-')) {
|
|
|
623fdc |
@@ -1674,7 +1677,8 @@ int uz_opts(__G__ pargc, pargv)
|
|
|
623fdc |
return(PK_PARAM);
|
|
|
623fdc |
}
|
|
|
623fdc |
s = *argv;
|
|
|
623fdc |
- strncpy(OEM_CP, s, sizeof(OEM_CP));
|
|
|
623fdc |
+ strncpy(OEM_CP, s, MAX_CP_NAME - 1);
|
|
|
623fdc |
+ OEM_CP[MAX_CP_NAME - 1] = '\0';
|
|
|
623fdc |
}
|
|
|
623fdc |
while(*(++s)); /* No params straight after charset name */
|
|
|
623fdc |
}
|
|
|
623fdc |
diff --git a/zipinfo.c b/zipinfo.c
|
|
|
623fdc |
index accca2a..cb7e08d 100644
|
|
|
623fdc |
--- a/zipinfo.c
|
|
|
623fdc |
+++ b/zipinfo.c
|
|
|
623fdc |
@@ -519,7 +519,8 @@ int zi_opts(__G__ pargc, pargv)
|
|
|
623fdc |
"error: a valid character encoding should follow the -I argument"));
|
|
|
623fdc |
return(PK_PARAM);
|
|
|
623fdc |
}
|
|
|
623fdc |
- strncpy(ISO_CP, s, sizeof(ISO_CP));
|
|
|
623fdc |
+ strncpy(ISO_CP, s, MAX_CP_NAME - 1);
|
|
|
623fdc |
+ ISO_CP[MAX_CP_NAME - 1] = '\0';
|
|
|
623fdc |
} else { /* -I charset */
|
|
|
623fdc |
++argv;
|
|
|
623fdc |
if(!(--argc > 0 && *argv != NULL && **argv != '-')) {
|
|
|
623fdc |
@@ -528,7 +529,8 @@ int zi_opts(__G__ pargc, pargv)
|
|
|
623fdc |
return(PK_PARAM);
|
|
|
623fdc |
}
|
|
|
623fdc |
s = *argv;
|
|
|
623fdc |
- strncpy(ISO_CP, s, sizeof(ISO_CP));
|
|
|
623fdc |
+ strncpy(ISO_CP, s, MAX_CP_NAME - 1);
|
|
|
623fdc |
+ ISO_CP[MAX_CP_NAME - 1] = '\0';
|
|
|
623fdc |
}
|
|
|
623fdc |
while(*(++s)); /* No params straight after charset name */
|
|
|
623fdc |
}
|
|
|
623fdc |
@@ -568,7 +570,8 @@ int zi_opts(__G__ pargc, pargv)
|
|
|
623fdc |
"error: a valid character encoding should follow the -I argument"));
|
|
|
623fdc |
return(PK_PARAM);
|
|
|
623fdc |
}
|
|
|
623fdc |
- strncpy(OEM_CP, s, sizeof(OEM_CP));
|
|
|
623fdc |
+ strncpy(OEM_CP, s, MAX_CP_NAME - 1);
|
|
|
623fdc |
+ OEM_CP[MAX_CP_NAME - 1] = '\0';
|
|
|
623fdc |
} else { /* -O charset */
|
|
|
623fdc |
++argv;
|
|
|
623fdc |
if(!(--argc > 0 && *argv != NULL && **argv != '-')) {
|
|
|
623fdc |
@@ -577,7 +580,8 @@ int zi_opts(__G__ pargc, pargv)
|
|
|
623fdc |
return(PK_PARAM);
|
|
|
623fdc |
}
|
|
|
623fdc |
s = *argv;
|
|
|
623fdc |
- strncpy(OEM_CP, s, sizeof(OEM_CP));
|
|
|
623fdc |
+ strncpy(OEM_CP, s, MAX_CP_NAME - 1);
|
|
|
623fdc |
+ OEM_CP[MAX_CP_NAME - 1] = '\0';
|
|
|
623fdc |
}
|
|
|
623fdc |
while(*(++s)); /* No params straight after charset name */
|
|
|
623fdc |
}
|
|
|
623fdc |
--
|
|
|
623fdc |
2.14.5
|
|
|
623fdc |
|