38 lines
1.4 KiB
Diff
38 lines
1.4 KiB
Diff
|
|
From e9c3024874007015ff7ebd66ecff086698b9db91 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Stuart Caie <kyzer@cabextract.org.uk>
|
||
|
|
Date: Wed, 17 Oct 2018 11:29:03 +0100
|
||
|
|
Subject: [PATCH] Avoid returning CHM file entries that are "blank" because
|
||
|
|
they have embedded null bytes (cherry picked from commit
|
||
|
|
8759da8db6ec9e866cb8eb143313f397f925bb4f)
|
||
|
|
|
||
|
|
https://github.com/kyz/libmspack/commit/8759da8db6ec9e866cb8eb143313f397f925bb4f
|
||
|
|
---
|
||
|
|
libmspack/mspack/chmd.c | 6 +++---
|
||
|
|
1 file changed, 3 insertions(+), 3 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/mspack/chmd.c b/mspack/chmd.c
|
||
|
|
index 014e71e..0f6c3a3 100644
|
||
|
|
--- a/mspack/chmd.c
|
||
|
|
+++ b/mspack/chmd.c
|
||
|
|
@@ -447,14 +447,14 @@ static int chmd_read_headers(struct mspack_system *sys, struct mspack_file *fh,
|
||
|
|
while (num_entries--) {
|
||
|
|
READ_ENCINT(name_len);
|
||
|
|
if (name_len > (unsigned int) (end - p)) goto chunk_end;
|
||
|
|
- /* consider blank filenames to be an error */
|
||
|
|
- if (name_len == 0) goto chunk_end;
|
||
|
|
name = p; p += name_len;
|
||
|
|
-
|
||
|
|
READ_ENCINT(section);
|
||
|
|
READ_ENCINT(offset);
|
||
|
|
READ_ENCINT(length);
|
||
|
|
|
||
|
|
+ /* ignore blank or one-char (e.g. "/") filenames we'd return as blank */
|
||
|
|
+ if (name_len < 2 || !name[0] || !name[1]) continue;
|
||
|
|
+
|
||
|
|
/* empty files and directory names are stored as a file entry at
|
||
|
|
* offset 0 with length 0. We want to keep empty files, but not
|
||
|
|
* directory names, which end with a "/" */
|
||
|
|
--
|
||
|
|
1.7.12.4
|
||
|
|
|