From 68dddd4132521dc72133a4f0010d0d07ec30a16e Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Thu, 22 Apr 2021 00:37:03 +0200 Subject: keysym: fix underflow in binary searches This is hit when passing an empty string and XKB_KEYSYM_CASE_INSENSITIVE to xkb_keysym_from_name currently if `(lo + hi) / 2` is 0 and `cmp < 0`, causing mid to underflow and the the array access into name_to_keysym on the next iteration of the loop to be out of bounds . We *would* use ssize_t here as it is the appropriate type, but windows unfortunately does not define it. --- test/keysym.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'test') diff --git a/test/keysym.c b/test/keysym.c index 0c3ba9f..2c98c24 100644 --- a/test/keysym.c +++ b/test/keysym.c @@ -189,6 +189,9 @@ main(void) assert(test_casestring("Thorn", 0x00fe)); assert(test_casestring("thorn", 0x00fe)); + assert(test_string("", XKB_KEY_NoSymbol)); + assert(test_casestring("", XKB_KEY_NoSymbol)); + assert(test_utf8(XKB_KEY_y, "y")); assert(test_utf8(XKB_KEY_u, "u")); assert(test_utf8(XKB_KEY_m, "m")); -- cgit v1.2.3