diff options
author | John-Mark Bell <jmb@netsurf-browser.org> | 2023-03-11 11:03:02 +0000 |
---|---|---|
committer | John-Mark Bell <jmb@netsurf-browser.org> | 2023-03-11 11:03:02 +0000 |
commit | dc839346e8a2032d0fe318b5c098af8e6e0cd76e (patch) | |
tree | 86c58765aa2c51705d179811cc0d7c5b16e6e03b /makerun.c | |
parent | a6a833a50b3287e6c719d9d5d54f909a894ebaa1 (diff) | |
download | makerun-dc839346e8a2032d0fe318b5c098af8e6e0cd76e.tar.gz makerun-dc839346e8a2032d0fe318b5c098af8e6e0cd76e.tar.bz2 |
Fix squeezed binary support
It turns out that the squeeze algorithm will always round the
uncompressed input data up to a multiple of 8 bytes before
compressing it. Update our expected size logic to reflect this.
Diffstat (limited to 'makerun.c')
-rw-r--r-- | makerun.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -41,7 +41,7 @@ int main(int argc, char **argv) FILE *f, *g; struct header header; long flen; - size_t file_size, reloc_size = 0; + size_t file_size, reloc_size = 0, expected_size = 0; char buf[256]; if (argc != 4) { @@ -70,6 +70,7 @@ int main(int argc, char **argv) fclose(f); return 1; } + expected_size = header.rosize + header.rwsize + header.dbsize; if ((header.decompress >> 24) == 0xEB) { /* Image is compressed */ @@ -113,6 +114,8 @@ int main(int argc, char **argv) } file_size = sizeof(header) + (size_t) sqzhdr.decsize; + /* Round expected size up to an even number of words */ + expected_size = (expected_size + 7) & ~7; } fclose(f); @@ -143,8 +146,7 @@ int main(int argc, char **argv) reloc_size += header.wkspace; } - if (header.rosize + header.rwsize + header.dbsize != - file_size) { + if (file_size != expected_size) { fprintf(stderr, "Mismatched field sizes\n"); return 1; } |