mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-21 21:25:25 +00:00
util/xml: fix extraction of XML context
Currently given an input of '<dom\n' we emit an error: error: Failed to define domain from tests/qemuxmlconfdata/broken-xml-invalid.xml error: at line 2: Couldn't find end of Start Tag dom line 1 (null) ^ With this fix we emit: error: Failed to define domain from tests/qemuxmlconfdata/broken-xml-invalid.xml error: at line 2: Couldn't find end of Start Tag dom line 1 <dom ----^ Reviewed-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Richard W.M. Jones <rjones@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
f7cbb136c3
commit
0635cd9555
@ -1047,6 +1047,11 @@ catchXMLError(void *ctx, const char *msg G_GNUC_UNUSED, ...)
|
||||
cur = ctxt->input->cur;
|
||||
base = ctxt->input->base;
|
||||
|
||||
/* skip backwards over NUL terminator, in case we failed
|
||||
* parsing at the EOF position */
|
||||
if ((cur > base) && *cur == '\0')
|
||||
cur--;
|
||||
|
||||
/* skip backwards over any end-of-lines */
|
||||
while ((cur > base) && ((*(cur) == '\n') || (*(cur) == '\r')))
|
||||
cur--;
|
||||
|
@ -1,3 +1,3 @@
|
||||
ABS_SRCDIR/qemuxmlconfdata/broken-xml-invalid.xml:2: Couldn't find end of Start Tag dom line 1
|
||||
(null)
|
||||
^
|
||||
<dom
|
||||
----^
|
||||
|
Loading…
Reference in New Issue
Block a user