aboutsummaryrefslogtreecommitdiff
path: root/archivers/lha/files/patch-dir_length_bounds_check
diff options
context:
space:
mode:
Diffstat (limited to 'archivers/lha/files/patch-dir_length_bounds_check')
-rw-r--r--archivers/lha/files/patch-dir_length_bounds_check20
1 files changed, 20 insertions, 0 deletions
diff --git a/archivers/lha/files/patch-dir_length_bounds_check b/archivers/lha/files/patch-dir_length_bounds_check
new file mode 100644
index 000000000000..7a0ae1e086e2
--- /dev/null
+++ b/archivers/lha/files/patch-dir_length_bounds_check
@@ -0,0 +1,20 @@
+--- src/header.c 2002-07-19 17:23:58.000000000 +0900
++++ src/header.c 2004-06-16 09:49:23.000000000 +0900
+@@ -648,8 +648,17 @@
+ }
+
+ if (dir_length) {
++ if ((dir_length + name_length) > sizeof(dirname)) {
++ fprintf(stderr, "Insufficient buffer size\n");
++ exit(112);
++ }
+ strcat(dirname, hdr->name);
+- strcpy(hdr->name, dirname);
++
++ if ((dir_length + name_length) > sizeof(hdr->name)) {
++ fprintf(stderr, "Insufficient buffer size\n");
++ exit(112);
++ }
++ strncpy(hdr->name, dirname, sizeof(hdr->name));
+ name_length += dir_length;
+ }