From 0d1c8999105402f4a2c9fe0f649672aa44f7fee5 Mon Sep 17 00:00:00 2001 From: Scott Tromley Date: Mon, 31 Aug 2026 09:03:08 -0400 Subject: [PATCH] Guard evdi_open_attached_to() against a NULL parent device evdi_open_attached_to_fixed() documents NULL as a valid argument meaning "open a generic device", and handles it: if (sysfs_parent_device == NULL) device_index = get_generic_device(); but the deprecated evdi_open_attached_to() wrapper calls strlen() on the pointer unconditionally, so passing NULL faults before that check can ever run: SIGSEGV si_code=SEGV_MAPERR si_addr=NULL #1 evdi_open_attached_to (libevdi.so.1 + 0x4523) Pass a length of 0 when the pointer is NULL, so the documented behaviour is reachable through the old entry point as well as the new one. This was reported in #582 and closed without the wrapper being changed, so the fault is still present. Co-Authored-By: Claude Opus 5 --- library/evdi_lib.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/evdi_lib.c b/library/evdi_lib.c index 5c437dfc..b05211f0 100644 --- a/library/evdi_lib.c +++ b/library/evdi_lib.c @@ -639,7 +639,9 @@ int evdi_add_device(void) // deprecated, use evdi_open_attached_to_fixed evdi_handle evdi_open_attached_to(const char *sysfs_parent_device) { - return evdi_open_attached_to_fixed(sysfs_parent_device, strlen(sysfs_parent_device)); + return evdi_open_attached_to_fixed( + sysfs_parent_device, + sysfs_parent_device ? strlen(sysfs_parent_device) : 0); } evdi_handle evdi_open_attached_to_fixed(const char *sysfs_parent_device, size_t length)