Skip to content

Commit cf19ac0

Browse files
committed
Update libmspack 0.10.1alpha to 0.11alpha
1 parent 7144658 commit cf19ac0

68 files changed

Lines changed: 1022 additions & 560 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

libclammspack/ChangeLog

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,148 @@
1+
2023-02-03 Stuart Caie <kyzer@cabextract.org.uk>
2+
3+
* configure.ac: do AC_CHECK_SIZEOF([off_t]) test only after
4+
AC_SYS_LARGEFILE, because the latter can alter the size of off_t.
5+
6+
* cabd_extract(): file->offset and file->length are unsigned ints,
7+
both of them and their sum are checked to be <= CAB_LENGTHMAX. But
8+
recent code stuffs file->length into an off_t and checks that instead.
9+
On 32-bit architectures, if file->length > 2GiB then the off_t is
10+
negative, evading the check. Ultimately this causes the decompression
11+
functions to return MSPACK_ERR_ARGS as they already guard against
12+
being asked to decompress a negative number of bytes.
13+
14+
2023-02-01 Stuart Caie <kyzer@cabextract.org.uk>
15+
16+
* readbits.h, readhuff.h, cabd.c, kwajd.c, lzxd.c, mszipd.c, qtmd.c:
17+
ensure bit operations (including intermediary ones) are considered
18+
as unsigned int, so UBSan is happy.
19+
20+
2023-01-31 Stuart Caie <kyzer@cabextract.org.uk>
21+
22+
* chmd.c: replace READ_ENCINT() macro with stricter read_encint()
23+
function that reads no more than 63 or 31 bits so ENCINTs can never
24+
be negative.
25+
26+
I'd prefer to use unsigned types, but off_t is used for file offsets
27+
and lengths to match the environment's file I/O, so changing it is
28+
tricky and would change the current public API.
29+
30+
Additionally, UBSan complains about shifting a 1 into a signed
31+
type's MSB. https://www.cs.utah.edu/~regehr/papers/tosem15.pdf
32+
notes that this is legal in ANSI C and "fairly benign (and well-
33+
defined until C99)", but C99 made it undefined for no good reason.
34+
I don't agree with this, but I don't want someone else using a C99
35+
compiler to end up miscompiling the code.
36+
37+
* chmd_read_headers(): the CHM's internally declared file length is
38+
compared against its actual file length and a warning is printed if
39+
they don't match.
40+
41+
* chmd_extract(): files in the uncompressed section will print a
42+
warning if their declared length goes beyond the declared end of the
43+
CHM file. This may not match the actual CHM file length. You will
44+
still get seek or read errors if a file's offset or length go beyond
45+
the actual CHM file length.
46+
47+
Files in the compressed section will now cause a decrunch error if
48+
their declared offset goes beyond the uncompressed length of the
49+
section. If their offset is OK but their declared length goes beyond
50+
the end, they will print a warning and then decompress as much as
51+
possible before causing an error.
52+
53+
2023-01-02 Stuart Caie <kyzer@cabextract.org.uk>
54+
55+
* kwajd_extract(): KWAJ compression method #2 is the QBasic variant
56+
of the SZDD compression algorithm. Thanks to Jason Summers for finding
57+
this and providing examples.
58+
59+
2021-07-20 Stuart Caie <kyzer@cabextract.org.uk>
60+
61+
* lzxd_decompress(): simplified the code that decodes match_offset.
62+
Thanks to Jasper St. Pierre for prompting me to look at it.
63+
64+
2020-12-30 Stuart Caie <kyzer@cabextract.org.uk>
65+
66+
* cabd_read_string(): libmspack no longer rejects CAB files with
67+
empty previnfo/nextinfo strings. Thanks to Simon Tatham for the
68+
patch, and for noting that WiX v4 currently generates such files.
69+
70+
2020-08-10 Stuart Caie <kyzer@cabextract.org.uk>
71+
72+
* lzxd_decompress(): merged the code for decoding aligned and
73+
verbatim blocks, also verified there is no significant performance
74+
penalty.
75+
76+
2020-08-07 Stuart Caie <kyzer@cabextract.org.uk>
77+
78+
* read_sys_file(): in a CHM file, the ControlData and ResetTable
79+
files are loaded entirely into memory, regardless of file size.
80+
This is not in the spirit of letting users control memory usage.
81+
82+
ControlData previously had to be at least 28 bytes (in case a new,
83+
larger version of the file ever appeared), but is now rejected
84+
if not exactly 28 bytes.
85+
86+
ResetTable can theoretically be huge; the longest LZX stream of
87+
16 exabytes could have a 4 petabyte ResetTable. Practically, the
88+
largest seen in the wild is 46 kilobytes (PHP manuals). I picked
89+
an arbitrary upper limit of 1MB; please get in contact if you
90+
know of any CHM files in the wild that are largest than this.
91+
92+
Thanks to seviezhou on Github for reporting this.
93+
94+
2020-04-13 Stuart Caie <kyzer@cabextract.org.uk>
95+
96+
* system.h: clear up libmspack's large file support.
97+
98+
To support large files, do this:
99+
100+
1. add any defines that your compiler needs to enable large file
101+
support. It may be supported by default.
102+
2. Define HAVE_FSEEKO if fseeko() and ftello() are available.
103+
3. Define SIZEOF_OFF_T to the value of sizeof(off_t); it must be a
104+
literal value because sizeof() can't be used in preprocessor tests.
105+
106+
libmspack uses the off_t datatype for all file offsets. If off_t is
107+
less than 64 bits, libmspack will return an error when processing
108+
CHM files with offsets beyond 2GB, and won't search for CAB headers
109+
beyond 2GB into a file. In both cases, it prints a warning message
110+
that the library doesn't support large files.
111+
112+
2020-04-13 Stuart Caie <kyzer@cabextract.org.uk>
113+
114+
* macros.h: new header for the D(), LD/LU and EndGet???() macros.
115+
Use this instead of system.h.
116+
117+
* system.h: if MSPACK_NO_DEFAULT_SYSTEM is defined, define
118+
inline versions of the only standard C functions used in
119+
mspack (strlen, memcmp, memset), so that no standard C library
120+
functions are needed at all.
121+
122+
2020-01-08 Stuart Caie <kyzer@cabextract.org.uk>
123+
124+
* lzxd_decompress(): do not apply the E8 transformation on the
125+
32769th LZX frame! Thanks to Cezary Sliwa for discovering this
126+
bug and providing an example cab file (which is
127+
http://download.windowsupdate.com/d/msdownload/update/driver/
128+
drvs/2019/11/016c7f3e-809d-4720-893b-
129+
e0d74f10c39d_35e12507628e8dc8ae5fb3332835f4253d2dab23.cab)
130+
131+
* cabd_compare: use EXPAND.EXE instead of EXTRACT.EXE when
132+
testing files in a directory called 'expand'. The example
133+
cab file above is extracted wrongly by EXTRACT.EXE, but
134+
correctly by EXPAND.EXE because they take different approaches
135+
to E8 transformations:
136+
137+
- EXTRACT.EXE writes "E8E8E8E8E8E8' to the last 6 bytes of
138+
frame, looks for E8 bytes up to the last 6 bytes, then restores
139+
the last 6 bytes, leaving partial transforms of 1-3 bytes if
140+
E8 byte is found near the end of the frame
141+
142+
- EXPAND.EXE looks for E8 bytes up to the last 10 bytes of a
143+
frame, therefore the last 6 bytes are never altered and all
144+
transforms are 4 bytes
145+
1146
2019-02-18 Stuart Caie <kyzer@cabextract.org.uk>
2147

3148
* chmd_read_headers(): a CHM file name beginning "::" but shorter

libclammspack/Makefile.am

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ TESTS = $(check_PROGRAMS)
55

66
ACLOCAL_AMFLAGS = -I m4
77
AM_CFLAGS =
8-
# add "-DMSPACK_NO_DEFAULT_SYSTEM" to remove default mspack_system
8+
# add "-DMSPACK_NO_DEFAULT_SYSTEM" to remove default mspack_system.
9+
# however, note that many of the tests and examples provided DO rely on the
10+
# default mspack_system and will fail without it -- any program with a call
11+
# like "mspack_create_...(NULL)" expects a default mspack_system.
912
if GCC
1013
AM_CFLAGS += -Wall -Wextra -Wno-unused-parameter -Wno-unused-result
1114
endif
@@ -34,7 +37,7 @@ libmspack_la_SOURCES = mspack/mspack.h \
3437
mspack/lzx.h mspack/lzxc.c mspack/lzxd.c \
3538
mspack/mszip.h mspack/mszipc.c mspack/mszipd.c \
3639
mspack/qtm.h mspack/qtmd.c \
37-
mspack/readbits.h mspack/readhuff.h \
40+
mspack/macros.h mspack/readbits.h mspack/readhuff.h \
3841
mspack/lzss.h mspack/lzssd.c \
3942
mspack/des.h mspack/sha.h \
4043
mspack/crc32.c mspack/crc32.h
@@ -46,14 +49,14 @@ libmscabd_la_SOURCES = mspack/mspack.h \
4649
mspack/lzx.h mspack/lzxd.c \
4750
mspack/mszip.h mspack/mszipd.c \
4851
mspack/qtm.h mspack/qtmd.c \
49-
mspack/readbits.h mspack/readhuff.h
52+
mspack/macros.h mspack/readbits.h mspack/readhuff.h
5053
libmscabd_la_LDFLAGS = -export-symbols-regex '^mspack_'
5154

5255
libmschmd_la_SOURCES = mspack/mspack.h \
5356
mspack/system.h mspack/system.c \
5457
mspack/chm.h mspack/chmd.c \
5558
mspack/lzx.h mspack/lzxd.c \
56-
mspack/readbits.h mspack/readhuff.h
59+
mspack/macros.h mspack/readbits.h mspack/readhuff.h
5760
libmschmd_la_LDFLAGS = -export-symbols-regex '^mspack_'
5861

5962
examples_cabd_memory_SOURCES = examples/cabd_memory.c libmscabd.la

libclammspack/README

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
libmspack 0.10.1alpha
1+
libmspack 0.11alpha
22

33
The purpose of libmspack is to provide compressors and decompressors,
44
archivers and dearchivers for Microsoft compression formats: CAB, CHM, WIM,
@@ -90,14 +90,15 @@ examples/msexpand.c - expands an SZDD or KWAJ file
9090
examples/oabextract.c - extracts an Exchange Offline Address Book (.LZX) file
9191

9292
test/cabd_c10 - tests the CAB decompressor on the C10 collection
93-
test/cabd_compare - compares libmspack with Microsoft's EXTRACT.EXE
93+
test/cabd_compare - compares libmspack with Microsoft's EXTRACT/EXPAND.EXE
9494
test/cabd_md5 - shows MD5 checksums of all files in a CAB file/set
9595
test/chmd_compare - compares libmspack with Microsoft's HH.EXE
9696
test/chmd_find.c - checks all files in a CHM file can be fast-found
9797
test/chmd_md5.c - shows MD5 checksums of all files within a CHM file
9898
test/chmd_order.c - extracts files in a CHM file in four different ways
9999
test/chminfo.c - prints verbose information about CHM file structures
100100
test/msdecompile_md5 - runs Microsoft's HH.EXE -DECOMPILE via WINE
101+
test/msexpand_md5 - runs Microsoft's EXPAND.EXE via WINE
101102
test/msextract_md5 - runs Microsoft's EXTRACT.EXE via WINE
102103

103104
Here is a simple example of usage, which will create a CAB decompressor,

libclammspack/cleanup.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
11
#!/bin/sh
22
# deletes all auto-generated / compiled files
3-
4-
for dir in . doc examples mspack test; do
5-
while read path; do
6-
chmod -R a+rwx $dir/$path 2>/dev/null
7-
rm -vrf $dir/$path
8-
done < $dir/.gitignore
9-
done
3+
git clean -dfX

libclammspack/configure.ac

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# -*- Autoconf -*-
22
# Process this file with autoconf to produce a configure script.
33
AC_PREREQ(2.59)
4-
AC_INIT([libmspack],[0.10.1alpha],[kyzer@cabextract.org.uk])
4+
AC_INIT([libmspack],[0.11alpha],[kyzer@cabextract.org.uk])
55
AC_CONFIG_MACRO_DIR([m4])
66
AM_INIT_AUTOMAKE([1.11])
77
AM_SILENT_RULES([yes])
88
AC_CONFIG_SRCDIR([mspack/mspack.h])
9-
AC_CONFIG_HEADER([config.h])
9+
AC_CONFIG_HEADERS([config.h])
1010

1111
# --enable-debug option
1212
AC_ARG_ENABLE(debug,
@@ -34,7 +34,6 @@ AC_C_BIGENDIAN
3434
AC_TYPE_MODE_T
3535
AC_TYPE_OFF_T
3636
AC_TYPE_SIZE_T
37-
AC_CHECK_SIZEOF([off_t])
3837

3938
# Checks for library functions
4039
AX_FUNC_MKDIR
@@ -43,6 +42,7 @@ AC_CHECK_FUNCS([towlower])
4342
# largefile support
4443
AC_SYS_LARGEFILE
4544
AC_FUNC_FSEEKO
45+
AC_CHECK_SIZEOF([off_t])
4646

4747
AC_CONFIG_FILES([Makefile libmspack.pc])
4848
AC_OUTPUT

libclammspack/doc/szdd_kwaj_format.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ <h1>COMPRESS.EXE file formats: SZDD and KWAJ</h1>
158158
<ol start="0">
159159
<li>No compression</li>
160160
<li>No compression, data is XORed with byte 0xFF</li>
161-
<li>The same compression method as regular SZDD</li>
161+
<li>The same compression method as the QBasic variant of SZDD</li>
162162
<li>LZ + Huffman "Jeff Johnson" compression</li>
163163
<li>MS-ZIP</li>
164164
</ol>

libclammspack/examples/cabrip.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <stdlib.h>
77
#include <sys/stat.h>
88
#include <mspack.h>
9-
#include "system.h"
9+
#include "mspack/macros.h"
1010

1111
#if HAVE_FSEEKO
1212
# define fseek fseeko

libclammspack/libmspack.cygport

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
NAME=libmspack
2-
VERSION=0.10.1
2+
VERSION=0.11
33
RELEASE=1
44
CATEGORY=Libs
55
SUMMARY="A library for Microsoft compression formats"

libclammspack/mspack/cabc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
/* CAB compression implementation */
1111

12-
#include "system.h"
13-
#include "cab.h"
12+
#include <system.h>
13+
#include <cab.h>
1414

1515
struct mscab_compressor *
1616
mspack_create_cab_compressor(struct mspack_system *sys)

0 commit comments

Comments
 (0)