Commit Graph

94 Commits

Author SHA1 Message Date
Mingjie Shen a2cc51bb14 udev_device.c: fix TOCTOU race condition (#57)
Separately checking the state of a file before operating on it may allow
an attacker to modify the file between the two operations.

Reference: CWE-367.
2023-12-05 11:41:24 +03:00
illiliti 99f1bc955a udev_device.c: stub udev_device_get_current_tags_list_entry impl 2023-07-10 14:13:58 +03:00
illiliti 04a727df50 udev_device.c: consider device valid even if no subsystem symlink exists
Some devices may not have subsystem symlinks, therefore we cannot rely
on that to check if device is valid. Instead, check uevent file which
should be always present in valid device.

Reference: https://github.com/openwrt/openwrt/issues/12350
2023-04-18 09:28:02 +03:00
Marc-André Moreau 4a28cc57e4 fix undefined LINE_MAX on Android 2022-04-15 10:14:22 -04:00
illiliti 7265d305c2 various: fix memory leaks
Closes: #41
2021-10-08 08:53:04 +03:00
illiliti caaa021290 udev_device.c: ignore devices without subsystem
Do not allocate udev_device if device doesn't have subsystem.

Fixes: #43
2021-10-08 08:36:20 +03:00
illiliti fc22990609 implement file-less hotplugging 2021-08-27 01:13:34 +00:00
illiliti d8c4dc4ce3 udev_device.c: define INPUT_PROP_CNT 2021-08-25 03:22:30 +03:00
illiliti 3d98bea289 *: code cleanup 2021-08-25 01:38:33 +03:00
illiliti bf23c9e5ba udev_device.c: fix integer overflow
Bitwise AND operation can produce value that may be larger than
test_bit() return value. Convert result to bool using `!!` to
avoid integer overflow.

Fixes: #33
2021-06-26 01:21:43 +03:00
illiliti e75aced4de udev_device.c: drop TODO 2021-06-06 10:52:20 +03:00
illiliti 7c94940e12 Revert "udev_device.c: use strrchr to trim newline"
This reverts commit 34f8727f28.
2021-06-06 10:50:38 +03:00
illiliti e23633ec56 udev_device.c: more accurate keys/keyboard detection 2021-06-06 10:29:55 +03:00
illiliti 34f8727f28 udev_device.c: use strrchr to trim newline 2021-06-06 10:29:55 +03:00
Naoto Yamaguchi 75a40e1040 Add license information to source files
Current libudev-zero source code doesn't have license information in source files.
This patch add license information to source files based on SPDX standard.
2021-06-05 07:38:25 +00:00
illiliti a81cb4444d udev_device.c: decrement size by 1
SUBSYSTEM == 9, not 10. same for others
2021-06-03 12:06:18 +03:00
illiliti 4cb97cd01e udev_device.c: use strncmp to compare uevent vars 2021-06-03 12:02:40 +03:00
illiliti e814cfa506 udev_device.c: fix possible uninitialized read 2021-06-03 11:20:51 +03:00
illiliti 0fd4054baf Revert "udev_device.c: replace strncmp with strcmp"
This reverts commit ff6cf67c23.
2021-06-03 07:24:19 +03:00
illiliti 53aa6f3b04 udev_device.c: abort if uevent file is malformed 2021-06-03 06:27:47 +03:00
illiliti ff6cf67c23 udev_device.c: replace strncmp with strcmp 2021-06-03 05:28:46 +03:00
illiliti 41d6cc9976 udev_device.c: avoid passing NULL to atoi 2021-06-03 03:21:56 +03:00
illiliti 93c48c86ec udev_device.c: nitpick 2021-06-01 22:08:00 +03:00
illiliti 3d97786f09 udev_device.c: drop PAGESIZE
glibc violates POSIX and does not define it.
2021-05-27 19:13:04 +03:00
illiliti f44332df5a various: drop udev_* prefix from static functions 2021-05-26 17:55:29 +03:00
illiliti 0ea1528dfc udev_device.c: simplify bounds checking 2021-05-26 14:33:27 +03:00
illiliti 4b044ae52c udev_device.c: avoid off-by-one overflow 2021-05-26 13:37:02 +03:00
illiliti 145e2c814f udev_device.c: attempt to fix incorrect bitmask handling
Reference #22
2021-05-25 15:34:24 +03:00
illiliti a885b93c3c udev_device.c: correctly handle multiline sysattrs
Changed arbitrary size of sysattr to PAGESIZE[0]. Not sure about binary
sysattrs because they may be > PAGESIZE. Either way, we need dynamic
allocation to handle them.

Trim only trailing newlines, not the first one. Now content of the
sysattr not getting truncated. By the way, do we need to trim carrige
return '\r' too?

[0] https://www.kernel.org/doc/Documentation/filesystems/sysfs.txt

> The buffer will always be PAGE_SIZE bytes in length. On i386, this
  is 4096.

Fixes #25
2021-05-21 05:49:41 +03:00
Arthur Williams 3d188e78e8 Treat devices with keys as keyboards
Some keyboards have an absolute axis and would erroneously not be treated
as a keyboard. Now any device with keys would have the ID_INPUT_KEY
property set.
2021-05-03 11:51:35 -05:00
Arthur Williams 048701fa5f Detect touch devices as touchscreen
The Goodix Capacitive TouchScreen on the pinephone was being detected as
a joystick instead of a touchscreen. This patch correctly marks it as a
touchscreen and allows it to work out of the box with libinput
2021-03-16 19:12:58 -05:00
illiliti 84dcea670c define INPUT_PROP_{POINTING_STICK,ACCELEROMETER}. fixes #11 2021-01-20 09:10:29 +03:00
illiliti d9bd4f3a19 implement udev_device_get_usec_since_initialized. fixes #12, closes #14 2021-01-20 09:05:42 +03:00
illiliti b90b0acc88 general code cleanup 2021-01-20 08:58:19 +03:00
illiliti 68b42a2404 implement udev_device_get_seqnum. closes #7 2020-11-11 20:49:20 +03:00
illiliti 4e31ed15b5 add todo 2020-11-11 20:37:54 +03:00
illiliti be97914ade move not implemented comment to the same line of function for easier parsability 2020-09-16 21:51:08 +03:00
illiliti 089e09e00a fix memory leak 2020-09-13 23:26:40 +03:00
illiliti 0c4d64fdac fix xorg crash introduced in https://github.com/freedesktop/xorg-xserver/commit/74b7427c41b4e4104af7abf70a996c086d3d7628 2020-09-01 14:03:07 +03:00
illiliti 14e187f1e2 check file size 2020-08-23 15:31:10 +03:00
illiliti 894aa48906 fix memory leak 2020-08-23 15:23:36 +03:00
illiliti b54f639cfd final fixes 2020-08-23 00:51:10 +03:00
illiliti bcd28de858 fix potential UB while reading sysattr 2020-08-16 14:00:03 +03:00
illiliti 408249b34b simplify key=val parsing 2020-08-16 12:53:13 +03:00
illiliti 752f500a90 grab properties from uevent 2020-08-15 12:20:24 +03:00
illiliti 508424a3a2 fix sysname 2020-08-15 07:39:02 +03:00
illiliti 380e7f8890 implement hotplugging support 2020-08-14 19:33:18 +03:00
illiliti 56bcf25461 minor fixes, add joystick support 2020-08-12 23:31:37 +03:00
illiliti dc75e2b44e correctly find ID_INPUT_KEY 2020-08-10 00:48:02 +03:00
illiliti ca956fa663 add support for tablets, pointing sticks and accelerometers 2020-08-09 07:05:09 +03:00