Repository navigation
dom: ignore NUL padding at the end of the xml data - #1146
Merged
Merged
Conversation
Some devices pad their Genicam data with NUL bytes and include them in the size they announce. libxml2 2.11 and later reject them with "Extra content at the end of the document", so the device fails to open with "Invalid Genicam data". Older libxml2 versions accepted them. Drop trailing NUL bytes from the size before handing the buffer to libxml2. Fixes AravisProject#1102
Contributor
|
Thanks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1102.
Some cameras pad their GenICam XML with NUL bytes and count them in the size from the
Local:URL (the SVS-Vistek one in the issue ends with</RegisterDescription>\n\0\0). With libxml2 2.11 or newer,_parse_memory()usesxmlCtxtReadMemory(), which rejects the padding with "Extra content at the end of the document", and the device fails to open with "Invalid Genicam data". The olderxmlSAXUserParseMemory()path accepts it, which is probably why this only shows up on some systems.This change strips trailing NUL bytes from the size before the buffer goes to libxml2, in both
_parse_memory()variants. It's the same idea xiaoqiangwang tested in the issue comments. A negative size still meansstrlen().Testing: I added a
/dom/trailing-nulcase totests/dom.cthat parses a small GenICam document followed by two NUL bytes, through botharv_dom_document_new_from_memory()andarv_gc_new(). I built against libxml2 2.13.8: the test fails on main ("Invalid document") and passes with the fix. With the system libxml2 2.9.13 it passes either way.meson testpasses all 7 suites, including fakegv, against both libxml2 versions. I don't have the camera, so I haven't tried it on real hardware.