Dear Maintainer,
Using macunpack from macutils to unpack a CompactPro archive results in an
error message
Header CRC mismatch: got 0x79c895e4, need 0xebae4ed4
However, the CPT file unpacks successfully using CompactPro 1.52 on an
emulated Macintosh.
It appears the problem is that macunpack uses (unsigned long) 64-bit integers
for the computation of the "Zip CRC", but the CRC computation of CompactPro
only uses 32 bits.
Patching several unsigned long -> uint32_t values allows macunpack to decode
the archive.
(This was reported 'downstream' as
https://bugs.launchpad.net/ubuntu/+source/macutils/+bug/2136046)
I would be willing to develop a patch, however I am not particularly familiar
with the development and build process you prefer, and extensively updating
the 16/32-bit dependencies in the code potentially touches many files.
I hope this is a properly formatted patch file with a minimal fix for the bug. I also submitted this patch downstream on Ubuntu Launchpad
Thanks, Joseph. I'll do some testing and try to get this uploaded within a few days. Eric
Finally getting around to looking at this. The patch includes this bit:
+- (void)fprintf(fd, "unsigned long %s_crcinit = %d;\n", name, init);
++ (void)fprintf(fd, "#include <stdint.h>\n\n");
++ if (bits == 16) {
++ (void)fprintf(fd, "uint16_t %s_crcinit = %d;\n", name, init);
++ } else {
++ (void)fprintf(fd, "uint32_t %s_crcinit = %d;\n", name, init);
++ }
Which changes the number of bits in the initial value, but this initial
value is used to initialize the global element defined in crc.c as:
unsigned long crcinit;
e.g., in macunpack/cpt.c:
crcinit = zip_crcinit;
and macunpack/crc.h still declares these as:
extern unsigned long arc_crcinit;
extern unsigned long binhex_crcinit;
extern unsigned long zip_crcinit;
which isn't modified by your patch, so the headers get out of sync with the
actual code generated by makecrc. It probably works in practice, but this
should be cleaned up before being uploaded.
Eric
Thanks for looking it over. Fair enough, my initial patch was deliberately intended to be minimal, but if you would prefer my updating the uses of the libraries I can do that, although the changes will touch several more files. I think I have it working on my local git repo, it will take me a bit for me to convert it into the patch format.
Eric-- How about the attached? It combines the previous minimal fix, and I think updates all the call sites for CRC routines.