After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 712528 - Some compressed files fail to load
Some compressed files fail to load
Status: RESOLVED FIXED
Product: libxml2
Classification: Platform
Component: general
git master
Other Mac OS
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2013-11-17 07:28 UTC by Mike Alexander
Modified: 2013-11-29 06:39 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to fix the problem (898 bytes, patch)
2013-11-17 07:28 UTC, Mike Alexander
none Details | Review
Corrected patch (1.47 KB, patch)
2013-11-17 07:42 UTC, Mike Alexander
none Details | Review
Test file that triggers the bug (4.00 KB, application/octet-stream)
2013-11-29 05:17 UTC, Mike Alexander
  Details

Description Mike Alexander 2013-11-17 07:28:36 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.
Comment 1 Mike Alexander 2013-11-17 07:42:10 UTC
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.
Comment 2 Daniel Veillard 2013-11-28 15:23:48 UTC
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
Comment 3 Mike Alexander 2013-11-28 18:41:38 UTC
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.
Comment 4 Daniel Veillard 2013-11-29 02:36:11 UTC
Okay, I understand :-)
Unfortunately the reproducer I had for the Fedora compose problem
was very large and isn't available anymore.

  thanks again !

Daniel
Comment 5 Mike Alexander 2013-11-29 05:16:15 UTC
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.
Comment 6 Mike Alexander 2013-11-29 05:17:56 UTC
Created attachment 263090 [details]
Test file that triggers the bug
Comment 7 Daniel Veillard 2013-11-29 05:37:42 UTC
  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
Comment 8 Mike Alexander 2013-11-29 06:39:22 UTC
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.