From e73f6a3899c9e7b56531bf676083779b604e96d3 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 10 Aug 2018 09:18:47 +1000 Subject: [PATCH] util: fail property parsing if the dimensions are 0 There is no use-case for a zero width/height in anything using that property. Signed-off-by: Peter Hutterer --- src/libinput-util.c | 2 +- test/test-misc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libinput-util.c b/src/libinput-util.c index 1e198a855..cb689029f 100644 --- a/src/libinput-util.c +++ b/src/libinput-util.c @@ -273,7 +273,7 @@ parse_dimension_property(const char *prop, size_t *w, size_t *h) if (sscanf(prop, "%dx%d", &x, &y) != 2) return false; - if (x < 0 || y < 0) + if (x <= 0 || y <= 0) return false; *w = (size_t)x; diff --git a/test/test-misc.c b/test/test-misc.c index c1cca24f0..8176a3e90 100644 --- a/test/test-misc.c +++ b/test/test-misc.c @@ -851,7 +851,7 @@ START_TEST(dimension_prop_parser) { "1x20", true, 1, 20 }, { "1x8000", true, 1, 8000 }, { "238492x428210", true, 238492, 428210 }, - { "0x0", true, 0, 0 }, + { "0x0", false, 0, 0 }, { "-10x10", false, 0, 0 }, { "-1", false, 0, 0 }, { "1x-99", false, 0, 0 }, @@ -861,7 +861,7 @@ START_TEST(dimension_prop_parser) { "abd", false, 0, 0 }, { "xabd", false, 0, 0 }, { "0xaf", false, 0, 0 }, - { "0x0x", true, 0, 0 }, + { "0x0x", false, 0, 0 }, { "x10", false, 0, 0 }, { NULL, false, 0, 0 } };