From d6b79a64e6065625f7b667a8c5acb0ed923c4569 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Tue, 23 Feb 2021 18:54:53 +0000 Subject: [PATCH] conf: stronger error reporting when parsing audio related params MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check for varuous mandatory elements and improve error message clarity Reviewed-by: Michal Privoznik Signed-off-by: Daniel P. Berrangé --- src/conf/domain_conf.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4da2b7642b..2ed6ac33a4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13804,6 +13804,11 @@ virDomainSoundDefParseXML(virDomainXMLOptionPtr xmlopt, if (audioNode) { g_autofree char *tmp = NULL; tmp = virXMLPropString(audioNode, "id"); + if (!tmp) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing audio 'id' attribute")); + goto error; + } if (virStrToLong_ui(tmp, NULL, 10, &def->audioId) < 0 || def->audioId == 0) { virReportError(VIR_ERR_XML_ERROR, @@ -13877,6 +13882,12 @@ virDomainAudioDefParseXML(virDomainXMLOptionPtr xmlopt G_GNUC_UNUSED, ctxt->node = node; type = virXMLPropString(node, "type"); + if (!type) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing audio 'type' attribute")); + goto error; + } + if ((def->type = virDomainAudioTypeTypeFromString(type)) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown audio type '%s'"), type); @@ -13884,6 +13895,11 @@ virDomainAudioDefParseXML(virDomainXMLOptionPtr xmlopt G_GNUC_UNUSED, } tmp = virXMLPropString(node, "id"); + if (!tmp) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("missing audio 'id' attribute")); + goto error; + } if (virStrToLong_ui(tmp, NULL, 10, &def->id) < 0 || def->id == 0) { virReportError(VIR_ERR_XML_ERROR,