[libvirt] [PATCH 3/4] conf: Fix XML ctxt swap in virDomainNetDefParseXML

John Ferlan posted 4 patches 6 years, 11 months ago
There is a newer version of this series
[libvirt] [PATCH 3/4] conf: Fix XML ctxt swap in virDomainNetDefParseXML
Posted by John Ferlan 6 years, 11 months ago
Alter the logic to return @tmpnode to ctxt->node in both the error
and non-error path when calling virDomainNetIPInfoParseXML.

Signed-off-by: John Ferlan <jferlan@redhat.com>
---
 src/conf/domain_conf.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ddcb76f05d..d550b467f7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11356,10 +11356,11 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
                 xmlNodePtr tmpnode = ctxt->node;
 
                 ctxt->node = cur;
-                if (virDomainNetIPInfoParseXML(_("interface host IP"),
-                                               ctxt, &def->hostIP) < 0)
-                    goto error;
+                rv = virDomainNetIPInfoParseXML(_("interface host IP"),
+                                                ctxt, &def->hostIP);
                 ctxt->node = tmpnode;
+                if (rv < 0)
+                    goto error;
             }
             if (!macaddr && virXMLNodeNameEqual(cur, "mac")) {
                 macaddr = virXMLPropString(cur, "address");
-- 
2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 3/4] conf: Fix XML ctxt swap in virDomainNetDefParseXML
Posted by Ján Tomko 6 years, 11 months ago
On Wed, Feb 20, 2019 at 09:46:58AM -0500, John Ferlan wrote:
>Alter the logic to return @tmpnode to ctxt->node in both the error
>and non-error path when calling virDomainNetIPInfoParseXML.
>

What is the motivation here?

On error, ctxt->node will be restored anyway to 'oldnode'.

Jano

>Signed-off-by: John Ferlan <jferlan@redhat.com>
>---
> src/conf/domain_conf.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
>diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>index ddcb76f05d..d550b467f7 100644
>--- a/src/conf/domain_conf.c
>+++ b/src/conf/domain_conf.c
>@@ -11356,10 +11356,11 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
>                 xmlNodePtr tmpnode = ctxt->node;
>
>                 ctxt->node = cur;
>-                if (virDomainNetIPInfoParseXML(_("interface host IP"),
>-                                               ctxt, &def->hostIP) < 0)
>-                    goto error;
>+                rv = virDomainNetIPInfoParseXML(_("interface host IP"),
>+                                                ctxt, &def->hostIP);
>                 ctxt->node = tmpnode;
>+                if (rv < 0)
>+                    goto error;
>             }
>             if (!macaddr && virXMLNodeNameEqual(cur, "mac")) {
>                 macaddr = virXMLPropString(cur, "address");
>-- 
>2.20.1
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 3/4] conf: Fix XML ctxt swap in virDomainNetDefParseXML
Posted by John Ferlan 6 years, 11 months ago

On 2/20/19 10:42 AM, Ján Tomko wrote:
> On Wed, Feb 20, 2019 at 09:46:58AM -0500, John Ferlan wrote:
>> Alter the logic to return @tmpnode to ctxt->node in both the error
>> and non-error path when calling virDomainNetIPInfoParseXML.
>>
> 
> What is the motivation here?
> 
> On error, ctxt->node will be restored anyway to 'oldnode'.
> 

Coverity whined, but I can drop this one and just keep local Coverity
happy.  If someday someone extracts this out and it's a problem, then
they can fix it then.

John

> Jano
> 
>> Signed-off-by: John Ferlan <jferlan@redhat.com>
>> ---
>> src/conf/domain_conf.c | 7 ++++---
>> 1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>> index ddcb76f05d..d550b467f7 100644
>> --- a/src/conf/domain_conf.c
>> +++ b/src/conf/domain_conf.c
>> @@ -11356,10 +11356,11 @@
>> virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
>>                 xmlNodePtr tmpnode = ctxt->node;
>>
>>                 ctxt->node = cur;
>> -                if (virDomainNetIPInfoParseXML(_("interface host IP"),
>> -                                               ctxt, &def->hostIP) < 0)
>> -                    goto error;
>> +                rv = virDomainNetIPInfoParseXML(_("interface host IP"),
>> +                                                ctxt, &def->hostIP);
>>                 ctxt->node = tmpnode;
>> +                if (rv < 0)
>> +                    goto error;
>>             }
>>             if (!macaddr && virXMLNodeNameEqual(cur, "mac")) {
>>                 macaddr = virXMLPropString(cur, "address");
>> -- 
>> 2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list