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 ----^ Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx> --- src/util/virxml.c | 4 ++++ tests/qemuxmlconfdata/broken-xml-invalid.x86_64-latest.err | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/util/virxml.c b/src/util/virxml.c index 51173303fe..91f736bf39 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -1047,6 +1047,10 @@ catchXMLError(void *ctx, const char *msg G_GNUC_UNUSED, ...) cur = ctxt->input->cur; base = ctxt->input->base; + /* skip backwards over NUL terminator */ + if ((cur > base) && *cur == '\0') + cur--; + /* skip backwards over any end-of-lines */ while ((cur > base) && ((*(cur) == '\n') || (*(cur) == '\r'))) cur--; diff --git a/tests/qemuxmlconfdata/broken-xml-invalid.x86_64-latest.err b/tests/qemuxmlconfdata/broken-xml-invalid.x86_64-latest.err index 35a1801371..a3bacd5d3a 100644 --- a/tests/qemuxmlconfdata/broken-xml-invalid.x86_64-latest.err +++ b/tests/qemuxmlconfdata/broken-xml-invalid.x86_64-latest.err @@ -1,3 +1,3 @@ ABS_SRCDIR/qemuxmlconfdata/broken-xml-invalid.xml:2: Couldn't find end of Start Tag dom line 1 -(null) -^ +<dom +----^ -- 2.46.0