GNOME Bugzilla – Bug 712528
Some compressed files fail to load
Last modified: 2013-11-29 06:39:22 UTC
Created attachment 260025 [details] [review] Patch to fix the problem There is a bug in xzlib.c which causes certain compressed XML files to fail to load correctly. The code in xz_decomp which attempts to verify the checksum and length of the expanded data fails if the checksum or length at the end of the file crosses a 1024 byte boundary. It calls gz_next4 to get those two values. This function uses the stream state in state->zstrm, but calls xz_avail which uses the state->strm stream info. This causes gz_next4 to signal a premature EOF if the data it is fetching crosses a 1024 byte boundary. I've attached a patch that fixes this, although there are other ways to fix it.
Created attachment 260026 [details] [review] Corrected patch I realized that my previous patch changed a macro that is used elsewhere in a way that wouldn't work in the other uses. This patch corrects that.
Oh very interesting ! This might be the cause of some weirdness I heard about but which were not debugged. I did hit that problem I think and failed to fix, disabling the test instead which wasn't good but allowed the work around https://bugzilla.redhat.com/show_bug.cgi?id=877567 I am pretty sure you understood and managed to nail down the actual problem, thanks a lot !!! Would you have a test file reproducing the problem that you could attach ? I firmly believe you found the actual fix so commiting this: https://git.gnome.org/browse/libxml2/commit/?id=a1313a6f8c48cc27b02f65aca6b04e6cd59d939a Daniel
Unfortunately my test file, such as it is, contains all of my financial data for the last several years so I'm reluctant to post it. I used this file to test my patch and it seemed to fix the problem. A number of others have run into this problem with GnuCash, but they are all in the same boat and don't really want to post their private data. That's why it didn't get fixed until it happened to one of the GnuCash developers.
Okay, I understand :-) Unfortunately the reproducer I had for the Fedora compose problem was very large and isn't available anymore. thanks again ! Daniel
I happened to notice that one of my old test files for GnuCash was just under 4K in length (compressed) so I added a bit to it to make it 4100 bytes long, which will trigger the error. This might help test the fix.
Created attachment 263090 [details] Test file that triggers the bug
Thanks, somehow this doesn't seems o reproduce the issue for me when trying back with pristine 2.9.0: thinkpad:~/XML -> ./xmllint --noout BalanceSheetTest.wontload thinkpad:~/XML -> ls -l BalanceSheetTest.wontload -rw-rw-r--. 1 veillard veillard 4100 Nov 29 13:22 BalanceSheetTest.wontload thinkpad:~/XML -> md5sum BalanceSheetTest.wontload 192a8d4425eae1c5f6e141e46415b667 BalanceSheetTest.wontload thinkpad:~/XML -> git status # HEAD detached at v2.9.0 # Untracked files: # (use "git add <file>..." to include in what will be committed) # # BalanceSheetTest.wontload ... don't worry too much about it :-) Daniel
xmllint doesn't fail for me either. It must be using a different API in libxml2 to read the file. If you try to open that file with GnuCash 2.4.x it will fail. It is using xmlCreateFileParserCtxt followed by xmlParseDocument to parse the document.