Skip to content

Commit 8759da8

Browse files
committed
Avoid returning CHM file entries that are "blank" because they have embedded null bytes
1 parent 944cc10 commit 8759da8

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Diff for: libmspack/ChangeLog

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2018-10-17 Stuart Caie <kyzer@cabextract.org.uk>
2+
3+
* chmd_read_headers(): again reject files with blank filenames, this
4+
time because their 1st or 2nd byte is null, not because their length
5+
is zero. Thanks again to Hanno Böck for finding the issue.
6+
17
2018-10-16 Stuart Caie <kyzer@cabextract.org.uk>
28

39
* Makefile.am: using automake _DEPENDENCIES for chmd_test appears to

Diff for: libmspack/mspack/chmd.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -447,14 +447,14 @@ static int chmd_read_headers(struct mspack_system *sys, struct mspack_file *fh,
447447
while (num_entries--) {
448448
READ_ENCINT(name_len);
449449
if (name_len > (unsigned int) (end - p)) goto chunk_end;
450-
/* consider blank filenames to be an error */
451-
if (name_len == 0) goto chunk_end;
452450
name = p; p += name_len;
453-
454451
READ_ENCINT(section);
455452
READ_ENCINT(offset);
456453
READ_ENCINT(length);
457454

455+
/* ignore blank or one-char (e.g. "/") filenames we'd return as blank */
456+
if (name_len < 2 || !name[0] || !name[1]) continue;
457+
458458
/* empty files and directory names are stored as a file entry at
459459
* offset 0 with length 0. We want to keep empty files, but not
460460
* directory names, which end with a "/" */

0 commit comments

Comments
 (0)