Debian Codegraph @

mspack/ChangeLog

raw
1 2023-02-12 Stuart Caie <[email protected]>
2
3 * chmd.c: add a default tolower() if MSPACK_NO_DEFAULT_SYSTEM is set.
4
5 2023-02-03 Stuart Caie <[email protected]>
6
7 * configure.ac: do AC_CHECK_SIZEOF([off_t]) test only after
8 AC_SYS_LARGEFILE, because the latter can alter the size of off_t.
9
10 * cabd_extract(): file->offset and file->length are unsigned ints,
11 both of them and their sum are checked to be <= CAB_LENGTHMAX. But
12 recent code stuffs file->length into an off_t and checks that instead.
13 On 32-bit architectures, if file->length > 2GiB then the off_t is
14 negative, evading the check. Ultimately this causes the decompression
15 functions to return MSPACK_ERR_ARGS as they already guard against
16 being asked to decompress a negative number of bytes.
17
18 2023-02-01 Stuart Caie <[email protected]>
19
20 * readbits.h, readhuff.h, cabd.c, kwajd.c, lzxd.c, mszipd.c, qtmd.c:
21 ensure bit operations (including intermediary ones) are considered
22 as unsigned int, so UBSan is happy.
23
24 2023-01-31 Stuart Caie <[email protected]>
25
26 * chmd.c: replace READ_ENCINT() macro with stricter read_encint()
27 function that reads no more than 63 or 31 bits so ENCINTs can never
28 be negative.
29
30 I'd prefer to use unsigned types, but off_t is used for file offsets
31 and lengths to match the environment's file I/O, so changing it is
32 tricky and would change the current public API.
33
34 Additionally, UBSan complains about shifting a 1 into a signed
35 type's MSB. https://www.cs.utah.edu/~regehr/papers/tosem15.pdf
36 notes that this is legal in ANSI C and "fairly benign (and well-
37 defined until C99)", but C99 made it undefined for no good reason.
38 I don't agree with this, but I don't want someone else using a C99
39 compiler to end up miscompiling the code.
40
41 * chmd_read_headers(): the CHM's internally declared file length is
42 compared against its actual file length and a warning is printed if
43 they don't match.
44
45 * chmd_extract(): files in the uncompressed section will print a
46 warning if their declared length goes beyond the declared end of the
47 CHM file. This may not match the actual CHM file length. You will
48 still get seek or read errors if a file's offset or length go beyond
49 the actual CHM file length.
50
51 Files in the compressed section will now cause a decrunch error if
52 their declared offset goes beyond the uncompressed length of the
53 section. If their offset is OK but their declared length goes beyond
54 the end, they will print a warning and then decompress as much as
55 possible before causing an error.
56
57 2023-01-02 Stuart Caie <[email protected]>
58
59 * kwajd_extract(): KWAJ compression method #2 is the QBasic variant
60 of the SZDD compression algorithm. Thanks to Jason Summers for finding
61 this and providing examples.
62
63 2021-07-20 Stuart Caie <[email protected]>
64
65 * lzxd_decompress(): simplified the code that decodes match_offset.
66 Thanks to Jasper St. Pierre for prompting me to look at it.
67
68 2020-12-30 Stuart Caie <[email protected]>
69
70 * cabd_read_string(): libmspack no longer rejects CAB files with
71 empty previnfo/nextinfo strings. Thanks to Simon Tatham for the
72 patch, and for noting that WiX v4 currently generates such files.
73
74 2020-08-10 Stuart Caie <[email protected]>
75
76 * lzxd_decompress(): merged the code for decoding aligned and
77 verbatim blocks, also verified there is no significant performance
78 penalty.
79
80 2020-08-07 Stuart Caie <[email protected]>
81
82 * read_sys_file(): in a CHM file, the ControlData and ResetTable
83 files are loaded entirely into memory, regardless of file size.
84 This is not in the spirit of letting users control memory usage.
85
86 ControlData previously had to be at least 28 bytes (in case a new,
87 larger version of the file ever appeared), but is now rejected
88 if not exactly 28 bytes.
89
90 ResetTable can theoretically be huge; the longest LZX stream of
91 16 exabytes could have a 4 petabyte ResetTable. Practically, the
92 largest seen in the wild is 46 kilobytes (PHP manuals). I picked
93 an arbitrary upper limit of 1MB; please get in contact if you
94 know of any CHM files in the wild that are largest than this.
95
96 Thanks to seviezhou on Github for reporting this.
97
98 2020-04-13 Stuart Caie <[email protected]>
99
100 * system.h: clear up libmspack's large file support.
101
102 To support large files, do this:
103
104 1. add any defines that your compiler needs to enable large file
105 support. It may be supported by default.
106 2. Define HAVE_FSEEKO if fseeko() and ftello() are available.
107 3. Define SIZEOF_OFF_T to the value of sizeof(off_t); it must be a
108 literal value because sizeof() can't be used in preprocessor tests.
109
110 libmspack uses the off_t datatype for all file offsets. If off_t is
111 less than 64 bits, libmspack will return an error when processing
112 CHM files with offsets beyond 2GB, and won't search for CAB headers
113 beyond 2GB into a file. In both cases, it prints a warning message
114 that the library doesn't support large files.
115
116 2020-04-13 Stuart Caie <[email protected]>
117
118 * macros.h: new header for the D(), LD/LU and EndGet???() macros.
119 Use this instead of system.h.
120
121 * system.h: if MSPACK_NO_DEFAULT_SYSTEM is defined, define
122 inline versions of the only standard C functions used in
123 mspack (strlen, memcmp, memset), so that no standard C library
124 functions are needed at all.
125
126 2020-01-08 Stuart Caie <[email protected]>
127
128 * lzxd_decompress(): do not apply the E8 transformation on the
129 32769th LZX frame! Thanks to Cezary Sliwa for discovering this
130 bug and providing an example cab file (which is
131 http://download.windowsupdate.com/d/msdownload/update/driver/
132 drvs/2019/11/016c7f3e-809d-4720-893b-
133 e0d74f10c39d_35e12507628e8dc8ae5fb3332835f4253d2dab23.cab)
134
135 * cabd_compare: use EXPAND.EXE instead of EXTRACT.EXE when
136 testing files in a directory called 'expand'. The example
137 cab file above is extracted wrongly by EXTRACT.EXE, but
138 correctly by EXPAND.EXE because they take different approaches
139 to E8 transformations:
140
141 - EXTRACT.EXE writes "E8E8E8E8E8E8' to the last 6 bytes of
142 frame, looks for E8 bytes up to the last 6 bytes, then restores
143 the last 6 bytes, leaving partial transforms of 1-3 bytes if
144 E8 byte is found near the end of the frame
145
146 - EXPAND.EXE looks for E8 bytes up to the last 10 bytes of a
147 frame, therefore the last 6 bytes are never altered and all
148 transforms are 4 bytes
149
150 2019-02-18 Stuart Caie <[email protected]>
151
152 * chmd_read_headers(): a CHM file name beginning "::" but shorter
153 than 33 bytes will lead to reading past the freshly-allocated name
154 buffer - checks for specific control filenames didn't take length
155 into account. Thanks to ADLab of Venustech for the report and
156 proof of concept.
157
158 2019-02-18 Stuart Caie <[email protected]>
159
160 * chmd_read_headers(): CHM files can declare their chunks are any
161 size up to 4GB, and libmspack will attempt to allocate that to
162 read the file.
163
164 This is not a security issue; libmspack doesn't promise how much
165 memory it'll use to unpack files. You can set your own limits by
166 returning NULL in a custom mspack_system.alloc() implementation.
167
168 However, it would be good to validate chunk size further. With no
169 offical specification, only empirical data is available. All files
170 created by hhc.exe have a chunk size of 4096 bytes, and this is
171 matched by all the files I've found in the wild, except for one
172 which has a chunk size of 8192 bytes, which was created by someone
173 developing a CHM file creator 15 years ago, and they appear to
174 have abandoned it, so it seems 4096 is a de-facto standard.
175
176 I've changed the "chunk size is not a power of two" warning to
177 "chunk size is not 4096", and now only allow chunk sizes between
178 22 and 8192 bytes. If you have CHM files with a larger chunk size,
179 please send them to me and I'll increase this upper limit.
180
181 Thanks to ADLab of Venustech for the report.
182
183 2019-02-18 Stuart Caie <[email protected]>
184
185 * oabd.c: replaced one-shot copying of uncompressed blocks (which
186 requires allocating a buffer of the size declared in the header,
187 which can be 4GB) with a fixed-size buffer. The buffer size is
188 user-controllable with the new msoab_decompressor::set_param()
189 method (check you have version 2 of the OAB decompressor), and
190 also controls the input buffer used for OAB's LZX decompression.
191
192 Reminder: compression formats can dictate how much memory is
193 needed to decompress them. If memory usage is a security concern
194 to you, write a custom mspack_system.alloc() that returns NULL
195 if "too much" memory is requested. Do not rely on libmspack adding
196 special heuristics to know not to request "too much".
197
198 Thanks to ADLab of Venustech for the report.
199
200 2018-11-03 Stuart Caie <[email protected]>
201
202 * configure.ac, doc/Makefile.in, doc/Doxyfile.in: remove these
203 template files and replace with static files. You can still build
204 the documentation with make -C doc
205
206 2018-11-03 Stuart Caie <[email protected]>
207
208 * Makefile.am, src: move the "useful" programs in src/ to examples/
209 and don't auto-install them. Even though they're useful, they are
210 intended as examples and aren't productised (no commmand-line
211 options, no man pages, etc.) -- if you disagree, feel free to
212 send in a patch
213
214 2018-11-01 Stuart Caie <[email protected]>
215
216 * cabd_extract(): would not do decompression for random-access
217 offsets if the folder type was LZX. This is a fairly major bug,
218 and affects any decompression where you skip directly to a file,
219 or decompress data out-of-order. Thanks to austin987 for alerting
220 me to this.
221
222 This bug was introduced by the recent 'salvage mode' patch. Even
223 though I'd reviewed all the differences in clamav's copy of
224 libmspack and said "wtf" to this particular change, I didn't
225 notice it was still in the resulting patch I merged. Mea culpa :)
226
227 * test/cabd_test.c: now has a regression test to cover this
228
229 2018-10-31 Stuart Caie <[email protected]>
230
231 * Makefile.am, test/*_test.c: use the automake test-suite system
232 with the test-suite programs (cabd_test, chmd_test, kwajd_test).
233 This also fixes a longstanding bugbear that these programs don't
234 access their test files using an absolute path. Now this is passed
235 to them and you can run them from any directory. Thanks to Richard
236 Jones for requesting this.
237
238 2018-10-31 Stuart Caie <[email protected]>
239
240 * configure.ac: require at least automake 1.11, use AM_SILENT_RULES
241 unconditionally
242
243 2018-10-30 Stuart Caie <[email protected]>
244
245 * configure.ac: remove obsolescent C library tests. AC_HEADER_STDC is
246 removed, and so are most checks for standard C headers. libmspack now
247 makes these assumptions:
248 - <ctype.h> <limits.h> <stdlib.h> <string.h> exist
249 - <ctype.h> defines tolower()
250 - <string.h> defines memset(), memcmp(), strlen()
251 - if towlower() exists, it's defined in <wctype.h>
252
253 2018-10-22 Stuart Caie <[email protected]>
254
255 * cabd.c: remove the only use of assert()
256
257 2018-10-20 Stuart Caie <[email protected]>
258
259 * src/chmextract.c: add anti "../" and leading slash protection to
260 chmextract. I'm not pleased about this. All the sample code provided
261 with libmspack is meant to be simple examples of library use, not
262 "productised" binaries. Making the "useful" code samples install
263 as binaries was a mistake. They were never intended to protect you
264 from unpacking archive files with relative/absolute paths, and I
265 would prefer that they never will be.
266
267 2018-10-17 Stuart Caie <[email protected]>
268
269 * cab.h: Make the CAB block input buffer one byte larger, to allow
270 a maximum-allowed-size input block and the special extra byte added
271 after the block by cabd_sys_read_block to help Quantum alignment.
272 Thanks to Henri Salo for reporting this.
273
274 2018-10-17 Stuart Caie <[email protected]>
275
276 * chmd_read_headers(): again reject files with blank filenames, this
277 time because their 1st or 2nd byte is null, not because their length
278 is zero. Thanks again to Hanno Böck for finding the issue.
279
280 2018-10-16 Stuart Caie <[email protected]>
281
282 * Makefile.am: using automake _DEPENDENCIES for chmd_test appears to
283 override the default dependencies (e.g. sources), so libchmd.la was no
284 longer considered a dependency of chmd_test. This breaks parallel
285 builds like "make -j4". Added libchmd.la explicitly to dependencies.
286 Thanks to Thomas Deutschmann for reporting this.
287
288 2018-10-16 Stuart Caie <[email protected]>
289
290 * cabd.c: add new parameter, MSCABD_PARAM_SALVAGE, which makes CAB file
291 reading and extraction more lenient, to allow damaged or mangled CABs
292 to be extracted. When enabled:
293 - cabd->open() won't reject cabinets with files that have invalid
294 folder indices or filenames. These files will simply be skipped
295 - cabd->extract() won't reject files with invalid lengths, but will
296 limit them to the maximum possible
297 - block output sizes over 32768 bytes won't be rejected
298 - invalid data block checksums won't be rejected
299
300 It's still possible for corrupted files to fail extraction, but more
301 data can be extracted before they do.
302
303 This new parameter doesn't affect the existing MSCABD_PARAM_FIXMSZIP
304 parameter, which ignores MSZIP decompression failures. You can enable
305 both at once.
306
307 Thanks to Micah Snyder from ClamAV for working with me to get this
308 feature into libmspack. This also helps ClamAV move towards using a
309 vanilla copy of libmspack without needing their own patchset.
310
311 2018-08-13 Stuart Caie <[email protected]>
312
313 * mspack.h: clarify that mspack_system.free() should allow NULL. If your
314 mspack_system implementation doesn't, it would already have crashed, as
315 there are several places where libmspack calls sys->free(NULL). This
316 change makes it official, and amends a few "if (x) sys->free(x)" cases
317 to the simpler "sys->free(x)" to make it clearer.
318
319 2018-08-09 Stuart Caie <[email protected]>
320
321 * Makefile.am: the test file cve-2015-4467-reset-interval-zero.chm is
322 detected by ClamAV as BC.Legacy.Exploit.CVE_2012_1458-1 "infected".
323 My hosting deletes anything that ClamAV calls "infected", so has been
324 continually deleting the official libmspack 0.7alpha release.
325
326 CVE-2012-1458 is the same issue as CVE-2015-4467: both libmspack, and
327 ClamAV using libmspack, could get a division-by-zero crash when the LZX
328 reset interval was zero. This was fixed years ago, but ClamAV still has
329 it as a signature, which today prevents me from releasing libmspack.
330
331 BC.Legacy.Exploit.CVE_2012_1458-1 is a bytecode signature, so I can't
332 see the exact trigger conditions, but I can see that it looks for the
333 "LZXC" signature of the LZX control file, so I've changed this to
334 "lzxc" and added a step in the Makefile to change it back to LZXC, so
335 I can release libmspack whether or not ClamAV keeps the signature.
336
337 2018-04-26 Stuart Caie <[email protected]>
338
339 * read_chunk(): the test that chunk numbers are in bounds was off
340 by one, so read_chunk() returned a pointer taken from outside
341 allocated memory that usually crashes libmspack when accessed.
342 Thanks to Hanno Böck for finding the issue and providing a sample.
343
344 * chmd_read_headers(): reject files with blank filenames. Thanks
345 again to Hanno Böck for finding the issue and providing a sample file.
346
347 2018-02-06 Stuart Caie <[email protected]>
348
349 * chmd.c: fixed an off-by-one error in the TOLOWER() macro, reported
350 by Dmitry Glavatskikh. Thanks Dmitry!
351
352 2017-11-26 Stuart Caie <[email protected]>
353
354 * kwajd_read_headers(): fix up the logic of reading the filename and
355 extension headers to avoid a one or two byte overwrite. Thanks to
356 Jakub Wilk for finding the issue.
357
358 * test/kwajd_test.c: add tests for KWAJ filename.ext handling
359
360 2017-10-16 Stuart Caie <[email protected]>
361
362 * test/cabd_test.c: update the short string tests to expect not only
363 MSPACK_ERR_DATAFORMAT but also MSPACK_ERR_READ, because of the recent
364 change to cabd_read_string(). Thanks to maitreyee43 for spotting this.
365
366 * test/msdecompile_md5: update the setup instructions for this script,
367 and also change the script so it works with current Wine. Again, thanks
368 to maitreyee43 for trying to use it and finding it not working.
369
370 2017-08-13 Stuart Caie <[email protected]>
371
372 * src/chmextract.c: support MinGW one-arg mkdir(). Thanks to AntumDeluge
373 for reporting this.
374
375 2017-08-13 Stuart Caie <[email protected]>
376
377 * read_spaninfo(): a CHM file can have no ResetTable and have a
378 negative length in SpanInfo, which then feeds a negative output length
379 to lzxd_init(), which then sets frame_size to a value of your choosing,
380 the lower 32 bits of output length, larger than LZX_FRAME_SIZE. If the
381 first LZX block is uncompressed, this writes data beyond the end of the
382 window. This issue was raised by ClamAV as CVE-2017-6419. Thanks to
383 Sebastian Andrzej Siewior for finding this by chance!
384
385 * lzxd_init(), lzxd_set_output_length(), mszipd_init(): due to the issue
386 mentioned above, these functions now reject negative lengths
387
388 2017-08-05 Stuart Caie <[email protected]>
389
390 * cabd_read_string(): add missing error check on result of read().
391 If an mspack_system implementation returns an error, it's interpreted
392 as a huge positive integer, which leads to reading past the end of the
393 stack-based buffer. Thanks to Sebastian Andrzej Siewior for explaining
394 the problem. This issue was raised by ClamAV as CVE-2017-11423
395
396 2016-04-20 Stuart Caie <[email protected]>
397
398 * configure.ac: change my email address to [email protected]
399
400 2015-05-10 Stuart Caie <[email protected]>
401
402 * cabd_read_string(): correct rejection of empty strings. Thanks to
403 Hanno Böck for finding the issue and providing a sample file.
404
405 2015-05-10 Stuart Caie <[email protected]>
406
407 * Makefile.am: Add subdir-objects option as suggested by autoreconf.
408
409 * configure.ac: Add AM_PROG_AR as suggested by autoreconf.
410
411 2015-01-29 Stuart Caie <[email protected]>
412
413 * system.h: if C99 inttypes.h exists, use its PRI{d,u}{32,64} macros.
414 Thanks to Johnathan Kollasch for the suggestion.
415
416 2015-01-18 Stuart Caie <[email protected]>
417
418 * lzxd_decompress(): the byte-alignment code for reading uncompressed
419 block headers presumed it could wind i_ptr back 2 bytes, but this
420 hasn't been true since READ_BYTES was allowed to read bytes straddling
421 two blocks, leaving just 1 byte in the read buffer. Thanks to Jakub
422 Wilk for finding the issue and providing a sample file.
423
424 * inflate(): off-by-one error. Distance codes are 0-29, not 0-30.
425 Thanks to Jakub Wilk again.
426
427 * chmd_read_headers(), search_chunk(): another fix for checking pointer
428 is within a chunk, thanks again to Jakub Wilk.
429
430 2015-01-17 Stuart Caie <[email protected]>
431
432 * GET_UTF8_CHAR(): Remove 5/6-byte encoding support and check decoded
433 chars are no more than U+10FFFF.
434
435 * chmd_init_decomp(): A reset interval of 0 is invalid. Thanks to
436 Jakub Wilk for finding the issue and providing a sample and patch.
437
438 2015-01-15 Stuart Caie <[email protected]>
439
440 * chmd_read_headers(): add a bounds check to prevent over-reading data,
441 which caused a segfault on 32-bit architectures. Thanks to Jakub Wilk.
442
443 * search_chunk(): change the order of pointer arithmetic operations to
444 avoid overflow during bounds checks, which lead to segfaults on 32-bit
445 architectures. Again, thanks to Jakub Wilk for finding this issue,
446 providing sample files and a patch.
447
448 2015-01-08 Stuart Caie <[email protected]>
449
450 * cabd_extract(): No longer uses broken state data if extracting from
451 folder 1, 2, 1 and setting up folder 2 fails. This prevents a jump to
452 null and thus segfault. Thanks to Jakub Wilk again.
453
454 * cabd_read_string: reject empty strings. They are not found in any
455 valid CAB files. Thanks to Hanno Böck for sending me an example.
456
457 2015-01-05 Stuart Caie <[email protected]>
458
459 * cabd_can_merge_folders(): disallow folder merging if the combined
460 folder would have more than 65535 data blocks.
461
462 * cabd_decompress(): disallow files if their offset, length or
463 offset+length is more than 65535*32768, the maximum size of any
464 folder. Thanks to Jakub Wilk for identifying the problem and providing
465 a sample file.
466
467 2014-04-20 Stuart Caie <[email protected]>
468
469 * readhuff.h: fixed the table overflow check, which allowed one more
470 code after capacity had been reached, resulting in a read of
471 uninitialized data inside the decoding table. Thanks to Denis Kroshin
472 for identifying the problem and providing a sample file.
473
474 2013-05-27 Stuart Caie <[email protected]>
475
476 * test/oabx.c: added new example command for unpacking OAB files.
477
478 2013-05-17 Stuart Caie <[email protected]>
479
480 * mspack.h: Support for decompressing a new file format, the Exchange
481 Offline Address Book (OAB). Thanks to David Woodhouse for writing
482 the implementation. I've bumped the version to 0.4alpha in celebration.
483
484 2012-04-15 Stuart Caie <[email protected]>
485
486 * chmd_read_headers(): More thorough validation of CHM header values.
487 Thanks to Sergei Trofimovich for finding sample files.
488
489 * read_reset_table(): Better test for overflow. Thanks again to
490 Sergei Trofimovich for generating a good example.
491
492 * test/chminfo.c: this test program reads the reset table by itself
493 and was also susceptible to the same overflow problems.
494
495 2012-03-16 Stuart Caie <[email protected]>
496
497 * Makefile.am, configure.ac: make the GCC warning flags conditional
498 on using the GCC compiler. Thanks to Dagobert Michelsen for letting
499 me know.
500
501 2011-11-25 Stuart Caie <[email protected]>
502
503 * lzxd_decompress(): Prevent matches that go beyond the start
504 of the LZX stream. Thanks to Sergei Trofimovich for testing
505 with valgrind and finding a corrupt sample file that exercises
506 this scenario.
507
508 2011-11-23 Stuart Caie <[email protected]>
509
510 * chmd_fast_find(): add a simple check against infinite PMGL
511 loops. Thanks to Sergei Trofimovich for finding sample files.
512 Multi-step PMGL/PMGI infinite loops remain possible.
513
514 2011-06-17 Stuart Caie <[email protected]>
515
516 * read_reset_table(): wasn't reading the right offset for getting
517 the LZX uncompressed length. Thanks to Sergei Trofimovich for
518 finding the bug.
519
520 2011-05-31 Stuart Caie <[email protected]>
521
522 * kwajd.c, mszipd.c: KWAJ type 4 files (MSZIP) are now supported.
523 Thanks to Clive Turvey for sending me the format details.
524
525 * doc/szdd_kwaj_format.html: Updated documentation to cover
526 KWAJ's MSZIP compression.
527
528 2011-05-11 Stuart Caie <[email protected]>
529
530 * cabd_find(): rethought how large vs small file support is
531 handled, as users were getting "library not compiled to support
532 large files" message on some small files. Now checks for actual
533 off_t overflow, rather than trying to preempt it.
534
535 2011-05-10: Stuart Caie <[email protected]>
536
537 * chmd.c: implemented fast_find()
538
539 * test/chmx.c: removed the multiple extraction orders, now it just
540 extracts in the fastest order
541
542 * test/chmd_order.c: new program added to test that different
543 extraction orders don't affect the results of extraction
544
545 * test/chmd_find.c: new program to test that fast_find() works.
546 Either supply your own filename to find, or it will try finding
547 every file in the CHM.
548
549 * configure.ac: because CHM fast find requires case-insensitive
550 comparisons, tolower() or towlower() are used where possible.
551 These functions and their headers are checked for.
552
553 * mspack.h: exposed struct mschmd_sec_mscompressed's spaninfo
554 and struct mschmd_header's first_pmgl, last_pmgl and chunk_cache
555 to the world. Check that the CHM decoder version is v2 or higher
556 before using them.
557
558 * system.c: set CHM decoder version to v2
559
560 2011-04-27: Stuart Caie <[email protected]>
561
562 * many files: Made C++ compilers much happier with libmspack.
563 Changed char * to const char * where possible.
564
565 * mspack.h: Changed user-supplied char * to const char *.
566 Unless you've written your own mspack_system implementation,
567 you will likely be unaffected.
568 If you have written your own mspack_system implementation:
569 1: change open() so it takes a const char *filename
570 2: change message() so it takes a const char *format
571 If you cast your function into the mspack_system struct,
572 you can change the cast instead of the function.
573
574 2011-04-27: Stuart Caie <[email protected]>
575
576 * Makefile.am: changed CFLAGS from "-Wsign-compare -Wconversion
577 -pedantic" to "-W -Wno-unused". This enables more warnings, and
578 disables these specific warnings which are now a hinderance.
579
580 2011-04-27: Stuart Caie <[email protected]>
581
582 * test/cabrip.c, test/chminfo.c: used macros from system.h for
583 printing offsets and reading 64-bit values, rather than
584 reinvent the wheel.
585
586 * cabd_can_merge_folders(): declare variables at the start of
587 a block so older C compilers won't choke.
588
589 * cabd_find(): avoid compiler complaints about non-initialised
590 variables. We know they'll get initialised before use, but the
591 compiler can't reverse a state machine to draw the same conclusion.
592
593 2011-04-26: Stuart Caie <[email protected]>
594
595 * configure.ac, mspack/system.h: Added a configure test to get
596 the size of off_t. If off_t is 8 bytes or more, we presume this
597 system has large file support. This fixes LFS detection for Fedora
598 x86_64 and Darwin/Mac OS X, neither of which declare FILESIZEBITS in
599 <limits.h>. It's not against the POSIX standard to do this: "A
600 definition of [FILESIZEBITS] shall be omitted from the <limits.h>
601 header on specific implementations where the corresponding value is
602 equal to or greater than the stated minimum, but where the value can
603 vary depending on the file to which it is applied."
604 (http://pubs.opengroup.org/onlinepubs/009695399/basedefs/limits.h.html)
605 Thanks to Edward Sheldrake for the patch.
606
607 2011-04-26: Stuart Caie <[email protected]>
608
609 * chmd.c: all 64-bit integer reads are now consolidated into
610 the read_off64() function
611
612 * chmd_read_headers(): this function has been made resilient
613 against accessing memory past the end of a chunk. Thanks to
614 Sergei Trofimovich for sending me examples and analysis.
615
616 * chmd_init_decomp(): this function now reads the SpanInfo file
617 if the ResetTable file isn't available, it also checks that each
618 system file it needs is large enough before accessing it, and
619 some of its code has been split into several new functions:
620 find_sys_file(), read_reset_table() and read_spaninfo()
621
622 2011-04-26: Stuart Caie <[email protected]>
623
624 * mspack.h, chmd.c: now reads the SpanInfo system file if the
625 ResetTable file isn't available. This adds a new spaninfo pointer
626 into struct mschmd_sec_mscompressed
627
628 2011-04-26: Stuart Caie <[email protected]>
629
630 * test/chminfo.c: more sanity checks for corrupted CHM files where
631 entries go past the end of a PMGL/PMGI chunk, thanks to
632 Sergei Trofimovich for sending me examples and analysis.
633
634 2011-04-25: Stuart Caie <[email protected]>
635
636 * cabd_merge(): Drew D'Addesio showed me spanning cabinets which
637 don't have all the CFFILE entries they should, but otherwise have
638 all necessary data for extraction. Changed the merging folders
639 test to be less strict; if folders don't exactly match, warn which
640 files are missing, but allow merging if at least one necessary
641 file is present.
642
643 2010-09-24: Stuart Caie <[email protected]>
644
645 * readhuff.h: Don't let build_decode_table() allow empty trees.
646 It's meant to be special case just for the LZX length tree, so
647 move that logic out to the LZX code. Thanks to Danny Kroshin for
648 discovering the bug.
649
650 * lzxd.c: Allow empty length trees, but not other trees. If
651 the length tree is empty, fail if asked to decode a length symbol.
652 Again, thanks to Danny Kroshin for discovering the bug.
653
654 2010-09-20: Stuart Caie <[email protected]>
655
656 * Makefile.am: Set EXTRA_DIST so it doesn't include .svn
657 directories in the distribution, but does include docs.
658
659 2010-09-20: Stuart Caie <[email protected]>
660
661 * Makefile.am, configure.ac: Use modern auto* practises; turn on
662 automake silent rules where possible, use "m4" directory for libtool
663 macros, use LT_INIT instead of AC_PROG_LIBTOOL and use AM_CPPFLAGS
664 instead of INCLUDES. Thanks to Sergei Trofimovich for the patch.
665
666 2010-09-15: Stuart Caie <[email protected]>
667
668 * many files: Made the code compile with C++
669 - Renamed all 'this' variables/parameters to 'self'
670 - Added casts to all memory allocations.
671 - Added extern "C" to header files with extern declarations.
672 - Made system.c include system.h.
673 - Changed the K&R-style headers to ANSI-style headers in md5.c
674
675 2010-08-04: Stuart Caie <[email protected]>
676
677 * many files: removed unnecessary <unistd.h> include
678
679 2010-07-19: Stuart Caie <[email protected]>
680
681 * cabd_md5.c, chmd_md5.c: Replace writing files to disk then
682 MD5summing them, with an MD5summer built into mspack_system.
683 Much, much faster results.
684
685 * qtmd_decompress(): Robert Riebisch pointed out a Quantum
686 data integrity check that could never be tripped, because
687 frame_todo is unsigned, so it will never be decremented
688 below zero. Replaced the check with one that assumes that
689 decrementing past zero wraps frame_todo round to a number
690 more than its maximum value (QTM_FRAME_SIZE).
691
692 2010-07-18: Stuart Caie <[email protected]>
693
694 * cabd.c: Special logic to pass cabd_sys_read() errors back
695 to cabd_extract() wasn't compatible with the decompressor
696 logic of returning the same error repeatedly once unpacking
697 fails. This meant that if decompressing failed because of
698 a read error, then the next file in the same folder would
699 come back as "no error", but the decompressed wouldn't have
700 even attempted to decompress the file. Added a new state
701 variable, read_error, with the same lifespan as a decompressor,
702 to pass the underlying reason for MSPACK_ERR_READ errors back.
703
704 * mszipd.c: improve MS-ZIP recovery by saving all the bytes
705 decoded prior to a block failing. This requires remembering
706 how far we got through the block, so the code has been made
707 slightly slower (about 0.003 seconds slower per gigabyte
708 unpacked) by removing the local variable window_posn
709 and keeping it in the state structure instead.
710
711 2010-07-16: Stuart Caie <[email protected]>
712
713 * Makefile.am: strange interactions. When -std=c99 is used,
714 my Ubuntu's <stdio.h> (libc6-dev 2.11.1-0ubuntu7.2) does NOT
715 define fseeko() unless _LARGEFILE_SOURCE is also defined. But
716 configure always uses -std=gnu99, not -std=c99, so its test
717 determines _LARGEFILE_SOURCE isn't needed but HAVE_FSEEKO is
718 true. The implicit fseeko definition has a 32-bit rather than
719 64-bit offset, which means the mode parameter is interpreted
720 as part of the offset, and the mode is taken from the stack,
721 which is generally 0 (SEEK_SET). This breaks all SEEK_CURs.
722 The code works fine when -std=c99 is not set, so just remove
723 it for the time being.
724
725 2010-07-12: Stuart Caie <[email protected]>
726
727 * system.c: Reject reading/writing a negative number of bytes.
728
729 * chmd.c: allow zero-length files to be seen. Previously they were
730 skipped because they were mistaken for directory entries.
731
732 2010-07-08: Stuart Caie <[email protected]>
733
734 * qtmd.c: Larry Frieson found an important bug in the Quantum
735 decoder. Window wraps flush all unwritten data to disk.
736 However, sometimes less data is needed, which makes
737 out_bytes negative, which is then passed to write(). Some
738 write() implementations treat negative sizes it as a large
739 positive integer and segfault trying to write the buffer.
740
741 * Makefile.am, test/*.c: fixed automake file so that the
742 package passes a "make distcheck".
743
744 2010-07-07: Stuart Caie <[email protected]>
745
746 * doc/szdd_kwaj_format.html: explain SZDD/KWAJ file format.
747
748 * lzssd.c: fixed SZDD decompression bugs.
749
750 * test/chmd_compare: Add scripts for comparing chmd_md5 against
751 Microsoft's own code.
752
753 * test/chmd_md5.c: remove the need to decompress everything
754 twice, as this is already in chmx.c if needed.
755
756 2010-07-06: Stuart Caie <[email protected]>
757
758 * many files: added SZDD and KWAJ decompression support.
759
760 2010-06-18: Stuart Caie <[email protected]>
761
762 * system.h: expanded the test for 64-bit largefile support so
763 it also works on 64-bit native operating systems where you
764 don't have to define _FILE_OFFSET_BITS.
765
766 2010-06-17: Stuart Caie <[email protected]>
767
768 * libmspack.pc.in: Added pkg-config support. Thanks to
769 Patrice Dumas for the patch.
770
771 2010-06-14: Stuart Caie <[email protected]>
772
773 * qtmd.c, lzxd.c, mszipd.c: created new headers, readbits.h and
774 readhuff.h, which bundle up the bit-reading and huffman-reading
775 code found in the MSZIP, LZX and Quantum decoders.
776
777 2010-06-11: Stuart Caie <[email protected]>
778
779 * qtmd_static_init(): Removed function in favour of static const
780 tables, same rationale as for lzxd_static_init().
781
782 * qtmd_read_input(), zipd_read_input(): After testing against my
783 set of CABs from the wild, I've found both these functions _need_
784 an extra EOF flag, like lzxd_read_input() has. So I've added
785 it. This means CABs get decoded properly AND there's no reading
786 fictional bytes.
787
788 2010-06-03: Stuart Caie <[email protected]>
789
790 * test/cabd_md5.c: updated this so it has better output and
791 doesn't need to be in the same directory as the files for multi-
792 part sets.
793
794 2010-05-20: Stuart Caie <[email protected]>
795
796 * qtmd_read_input(), zipd_read_input(): Both these functions are
797 essentially copies of lzxd_read_input(), but that has a feature
798 they don't have - an extra EOF flag. So if EOF is
799 encountered (sys->read() returns 0 bytes), these don't pass on the
800 error. Their respective bit-reading functions that called them
801 then go on to access at least one byte of the input buffer, which
802 doesn't exist as sys->read() returned 0. Thanks to Michael
803 Vidrevich for spotting this and providing a test case.
804
805 2010-05-20: Stuart Caie <[email protected]>
806
807 * system.h: It turns out no configure.ac tests are needed to
808 decide between __func__ and __FUNCTION__, so I put the standard
809 one (__func__) back into the D() macro, along with some
810 special-case ifdefs for old versions of GCC.
811
812 * lzxd_static_init(): Removed function in favour of static const
813 tables. Jorge Lodos thinks it causes multithreading problems, I
814 disagree. However, there are speed benefits to declaring the
815 tables as static const.
816
817 * cabd_init_decomp(): Fixed code which never runs but would write
818 to a null pointer if it could. Changed it to an assert() as it
819 will only trip if someone rewrites the internals of cabd.c. Thanks
820 to Jorge Lodos for finding it.
821
822 * inflate(): Fixed an off-by-one error: if the LITERAL table
823 emitted code 286, this would read one byte past the end of
824 lit_extrabits[]. Thanks to Jorge Lodos for finding it.
825
826 2010-05-06: Stuart Caie <[email protected]>
827
828 * test/cabrip.c, test/chminfo.c: add fseeko() support
829
830 2009-06-01: Stuart Caie <[email protected]>
831
832 * README: clarify the extended license terms
833
834 * doc, Makefile.am: make the doxygen makefile work when using
835 an alternate build directory
836
837 2006-09-20: Stuart Caie <[email protected]>
838
839 * system.h: I had a choice of adding more to configure.ac to
840 test for __func__ and __FUNCTION__, or just removing __FUNCTION__
841 from the D() macro. I chose the latter.
842
843 * Makefile.am: Now the --enable-debug in configure will actually
844 apply -DDEBUG to the sources.
845
846 2006-09-20: Stuart Caie <[email protected]>
847
848 * qtmd_decompress(): Fixed a major bug in the QTM decoder, as
849 reported by Tomasz Kojm last year. Removed the restriction on
850 window sizes as a result. Correctly decodes the XLVIEW cabinets.
851
852 2006-08-31: Stuart Caie <[email protected]>
853
854 * lzxd_decompress(): Two major bugs fixed. Firstly, the R0/R1/R2
855 local variables weren't set to 1 after lzxd_reset_state().
856 Secondly, the LZX decompression stream can sometimes become
857 odd-aligned (after an uncompressed block) and the next 16 bit
858 fetch needs to be split across two input buffers, ENSURE_BITS()
859 didn't cover this case. Many thanks to Igor Glucksmann for
860 discovering both these bugs.
861
862 2005-06-30: Stuart Caie <[email protected]>
863
864 * cabd_search(): fixed problems with searching files > 4GB for
865 cabinets.
866
867 2005-06-23: Stuart Caie <[email protected]>
868
869 * qtmd_init(): The QTM decoder is broken for QTM streams with a
870 window size less than the frame size. Until this is fixed, fail
871 to initialise QTM window sizes less than 15. Thanks to Tomasz Kojm
872 for finding the bug.
873
874 2005-03-22: Stuart Caie <[email protected]>
875
876 * system.h: now undefs "read", as the latest glibc defines read()
877 as a macro which messes everything up. Thanks to Ville Skyttä for
878 the update.
879
880 2005-03-14: Stuart Caie <[email protected]>
881
882 * test/multifh.c: write an mspack_system implementation that can
883 handle normal disk files, open file handles, open file descriptors
884 and raw memory all at the same time.
885
886 2005-02-24: Stuart Caie <[email protected]>
887
888 * chmd_read_headers(): avoid infinite loop when chmhs1_ChunkSize is
889 zero. Thanks to Serge Semashko for the research and discovery.
890
891 2005-02-18: Stuart Caie <[email protected]>
892
893 * mspack.h: renamed the "interface" parameter of mspack_version() to
894 "entity", as interface is a reserved word in C++. Thanks to Yuriy Z
895 for the discovery.
896
897 2004-12-09: Stuart Caie <[email protected]>
898
899 * lzss.h, szdd.h, szddd.h: more work on the SZDD/LZSS design.
900
901 2004-06-12: Stuart Caie <[email protected]>
902
903 * lzxd_static_init(): removed write to lzxd_extra_bits[52], thanks
904 to Nigel Horne from the ClamAV project.
905
906 2004-04-23: Stuart Caie <[email protected]>
907
908 * mspack.h: changed 'this' parameters to 'self' to allow compiling in
909 C++ compilers, thanks to Michal Cihar for the suggestion.
910
911 * mspack.h, system.h, mspack.def, winbuild.sh: integrated some changes
912 from Petr Blahos to let libmspack build as a Win32 DLL.
913
914 * chmd_fast_find(): added the first part of this code, and comments
915 sufficient to finish it :)
916
917 2004-04-08 Stuart Caie <[email protected]>
918
919 * test/chminfo.c: added a program for dumping useful data from CHM
920 files, e.g. index entries and reset tables. I wrote this a while ago
921 for investigating a corrupt cabinet, but I never committed it.
922
923 2004-03-26 Stuart Caie <[email protected]>
924
925 * test/cabd_memory.c: added a new test example which shows an
926 mspack_system implementation that reads and writes from memory only,
927 no file I/O. Even the source code has a little cab file embedded in it.
928
929 2004-03-10 Stuart Caie <[email protected]>
930
931 * cabd.c: updated the location of the CAB SDK.
932
933 * cabd.c: changed a couple of MSPACK_ERR_READ errors not based on
934 read() failures into MSPACK_ERR_DATAFORMAT errors.
935
936 * mszipd_decompress(): repair mode now aborts after writing a
937 repaired block if the error was a hard error (e.g. read error, out
938 of blocks, etc)
939
940 2004-03-08 Stuart Caie <[email protected]>
941
942 * Makefile.am: now builds and installs a versioned library.
943
944 * mszipd.c: completed a new MS-ZIP and inflate implementation.
945
946 * system.c: added mspack_version() and committed to a versioned
947 ABI for the library.
948
949 * cabd.c: made mszip repair functionality work correctly.
950
951 * cabd.c: now identifies invalid block headers
952
953 * doc/: API documentation is now included with the library, not
954 just on the web.
955
956 * chmd.c: fixed error messages and 64-bit debug output.
957
958 * chmd.c: now also catches NULL files in section 1.
959
960 * test/chmx.c: now acts more like cabextract.
961
962 2003-08-29 Stuart Caie <[email protected]>
963
964 * ChangeLog: started keeping a ChangeLog :)