Skip to content

Commit 20acc2c

Browse files
scotttromleyclaude
authored andcommitted
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 <[email protected]>
1 parent 3609bef commit 20acc2c

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎library/evdi_lib.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,9 @@ int evdi_add_device(void)
639639
// deprecated, use evdi_open_attached_to_fixed
640640
evdi_handle evdi_open_attached_to(const char *sysfs_parent_device)
641641
{
642-
return evdi_open_attached_to_fixed(sysfs_parent_device, strlen(sysfs_parent_device));
642+
return evdi_open_attached_to_fixed(
643+
sysfs_parent_device,
644+
sysfs_parent_device ? strlen(sysfs_parent_device) : 0);
643645
}
644646

645647
evdi_handle evdi_open_attached_to_fixed(const char *sysfs_parent_device, size_t length)

0 commit comments

Comments
 (0)