From a8e6c36941028272697bac8dbfa8b365c181b01d Mon Sep 17 00:00:00 2001 From: Leon Henrik Plickat Date: Mon, 14 Aug 2023 14:48:35 +0200 Subject: [PATCH] better check for bad colours --- wayneko.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wayneko.c b/wayneko.c index 99d9001..eb5809b 100644 --- a/wayneko.c +++ b/wayneko.c @@ -911,6 +911,12 @@ static void timespec_diff (struct timespec *a, struct timespec *b, struct timesp static bool colour_from_hex (pixman_color_t *colour, const char *hex) { + if ( strlen(hex) != strlen("0xRRGGBBAA") && strlen(hex) != strlen("0xRRGGBB") ) + { + fprintf(stderr, "ERROR: Invalid colour: %s\n", hex); + return false; + } + uint16_t r = 0, g = 0, b = 0, a = 255; if ( 4 != sscanf(hex, "0x%02hx%02hx%02hx%02hx", &r, &g, &b, &a)