mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-04 04:40:25 +01:00
path: limit path device nodes to PATH_MAX characters
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
4353ed9152
commit
df527b07b4
2 changed files with 40 additions and 0 deletions
|
|
@ -331,6 +331,13 @@ libinput_path_add_device(struct libinput *libinput,
|
|||
struct udev_device *udev_device;
|
||||
struct libinput_device *device;
|
||||
|
||||
if (strlen(path) > PATH_MAX) {
|
||||
log_bug_client(libinput,
|
||||
"Unexpected path, limited to %d characters.\n",
|
||||
PATH_MAX);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (libinput->interface_backend != &interface_backend) {
|
||||
log_bug_client(libinput, "Mismatching backends.\n");
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -190,6 +190,38 @@ START_TEST(path_create_invalid_file)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(path_create_pathmax_file)
|
||||
{
|
||||
struct libinput *li;
|
||||
struct libinput_device *device;
|
||||
char *path;
|
||||
struct counter counter;
|
||||
|
||||
path = zalloc(PATH_MAX * 2);
|
||||
memset(path, 'a', PATH_MAX * 2 - 1);
|
||||
|
||||
counter.open_func_count = 0;
|
||||
counter.close_func_count = 0;
|
||||
|
||||
li = libinput_path_create_context(&counting_interface, &counter);
|
||||
|
||||
litest_set_log_handler_bug(li);
|
||||
ck_assert(li != NULL);
|
||||
device = libinput_path_add_device(li, path);
|
||||
ck_assert(device == NULL);
|
||||
|
||||
ck_assert_int_eq(counter.open_func_count, 0);
|
||||
ck_assert_int_eq(counter.close_func_count, 0);
|
||||
|
||||
litest_restore_log_handler(li);
|
||||
libinput_unref(li);
|
||||
ck_assert_int_eq(counter.close_func_count, 0);
|
||||
|
||||
free(path);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST(path_create_destroy)
|
||||
{
|
||||
struct libinput *li;
|
||||
|
|
@ -987,6 +1019,7 @@ TEST_COLLECTION(path)
|
|||
litest_add_no_device("path:create", path_create_invalid);
|
||||
litest_add_no_device("path:create", path_create_invalid_file);
|
||||
litest_add_no_device("path:create", path_create_invalid_kerneldev);
|
||||
litest_add_no_device("path:create", path_create_pathmax_file);
|
||||
litest_add_no_device("path:create", path_create_destroy);
|
||||
litest_add("path:create", path_force_destroy, LITEST_ANY, LITEST_ANY);
|
||||
litest_add_no_device("path:create", path_set_user_data);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue