diff options
author | John Chadwick <johnwchadwick@gmail.com> | 2019-09-26 20:06:11 -0700 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2019-10-16 13:38:11 +1000 |
commit | a7d2b749f3856373a9722648518bee39747a791f (patch) | |
tree | 4a82f7cd1582c86e5c9e4183cf804fbccb75014f | |
parent | c8daa2c0a196681d6ee424b15c1b4589794f7970 (diff) | |
download | libinput-a7d2b749f3856373a9722648518bee39747a791f.tar.gz |
test: Make udev_properties array fixed-size.
The udev_properties array is currently variable length, which causes the
tests to invoke undefined behavior on empty lists, as it attempts to
access the first array item to check if the key is NULL, which is an out
of bounds read and will fail when the struct alignment happens to line
up such that there is no padding after the list in the empty list case.
By making the udev_properties array 32 items long, it can encapsulate
every existing case, with only a fairly small amount of memory overhead,
and without requiring every single `TEST_DEVICE` call to initialize
`udev_properties`.
(cherry picked from commit b71a1b6e2daff58f3ef761106e43dc17666edae2)
-rw-r--r-- | test/litest-int.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/test/litest-int.h b/test/litest-int.h index 24d60874..598c8d0a 100644 --- a/test/litest-int.h +++ b/test/litest-int.h @@ -77,7 +77,7 @@ struct litest_test_device { const char *udev_rule; const char *quirk_file; - const struct key_value_str udev_properties[]; + const struct key_value_str udev_properties[32]; }; struct litest_device_interface { |