[libvirt] [PATCH 4/5] conf: ensure both resolution values are non-zero

Jonathon Jongsma posted 5 patches 6 years, 3 months ago
There is a newer version of this series
[libvirt] [PATCH 4/5] conf: ensure both resolution values are non-zero
Posted by Jonathon Jongsma 6 years, 3 months ago
Since the users of the resolution expect the x and y values to be
non-zero, enforce it in the parser and report an error if either is
zero.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
---
 src/conf/domain_conf.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a446ce4d62..38f8b37b69 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -15382,6 +15382,12 @@ virDomainVideoResolutionDefParseXML(xmlNodePtr node)
         return NULL;
     }
 
+    if (def->x == 0 || def->y == 0) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("resolution values must be greater than 0"));
+        return NULL;
+    }
+
     return g_steal_pointer(&def);
 }
 
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 4/5] conf: ensure both resolution values are non-zero
Posted by Ján Tomko 6 years, 3 months ago
On Fri, Oct 18, 2019 at 04:40:22PM -0500, Jonathon Jongsma wrote:
>Since the users of the resolution expect the x and y values to be
>non-zero, enforce it in the parser and report an error if either is
>zero.
>
>Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
>---
> src/conf/domain_conf.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>

This only works when somebody explicitly specifies x='0', but does not
catch the case where x is omitted from the XML completely

Jano
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 4/5] conf: ensure both resolution values are non-zero
Posted by Jonathon Jongsma 6 years, 3 months ago
On Wed, 2019-10-23 at 12:24 +0200, Ján Tomko wrote:
> On Fri, Oct 18, 2019 at 04:40:22PM -0500, Jonathon Jongsma wrote:
> > Since the users of the resolution expect the x and y values to be
> > non-zero, enforce it in the parser and report an error if either is
> > zero.
> > 
> > Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
> > ---
> > src/conf/domain_conf.c | 6 ++++++
> > 1 file changed, 6 insertions(+)
> > 
> 
> This only works when somebody explicitly specifies x='0', but does
> not
> catch the case where x is omitted from the XML completely
> 

That's true with respect to the changes within this diff, but earlier
in the function we already ensure that 'x' and 'y' are non-null. So if
the attributes were omitted, we would have already failed before this
point.

Jonathon

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