From: Pavel Hrdina Date: Wed, 25 Jan 2017 16:42:07 +0000 (+0100) Subject: domain_conf: vnc: preserve autoport value if no port was specified X-Git-Tag: CVE-2017-2635~227 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f19390d2d3ab18cc9bff53e1d642e4e2b534f5a5;p=thirdparty%2Flibvirt.git domain_conf: vnc: preserve autoport value if no port was specified The issue is that if this graphics definition is provided: it's parsed as: but if the resulting XML is parsed again the output is: and this should not happen. The XML have to always remain the same after it was already parsed by libvirt. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1383039 Signed-off-by: Pavel Hrdina --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a2b72cb9c5..877a0bf5c1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11722,6 +11722,8 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDefPtr def, if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) def->data.vnc.port = 0; def->data.vnc.autoport = true; + } else { + def->data.vnc.autoport = false; } } diff --git a/tests/genericxml2xmlindata/generic-graphics-vnc-autoport-no.xml b/tests/genericxml2xmlindata/generic-graphics-vnc-autoport-no.xml new file mode 100644 index 0000000000..748e7f489d --- /dev/null +++ b/tests/genericxml2xmlindata/generic-graphics-vnc-autoport-no.xml @@ -0,0 +1,30 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + + + + + + + + + + diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c index 2ea2396480..488190270f 100644 --- a/tests/genericxml2xmltest.c +++ b/tests/genericxml2xmltest.c @@ -91,6 +91,7 @@ mymain(void) DO_TEST_DIFFERENT("graphics-vnc-socket-attr-listen-socket"); DO_TEST_FULL("graphics-vnc-socket-attr-listen-socket-mismatch", 0, false, TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); + DO_TEST("graphics-vnc-autoport-no"); DO_TEST_FULL("name-slash-fail", 0, false, TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);