Skip to content

Commit

Permalink
util: fail property parsing if the dimensions are 0
Browse files Browse the repository at this point in the history
There is no use-case for a zero width/height in anything using that property.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
  • Loading branch information
whot committed Aug 13, 2018
1 parent c8e0e94 commit e73f6a3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/libinput-util.c
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions test/test-misc.c
Expand Up @@ -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 },
Expand All @@ -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 }
};
Expand Down

0 comments on commit e73f6a3

Please sign in to comment.