Skip to content

Commit

Permalink
guess/touchscreen: Check that the string read from sysfs is not empty
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Gladkov <[email protected]>
  • Loading branch information
legionus committed Aug 7, 2024
1 parent 0834246 commit 7b1f1a8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions guess/touchscreen/action
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,21 @@ for i in "$SYSFS_PATH"/class/input/event*/device/properties; do
[ -f "$i" ] ||
continue

prop=
readline prop "$i"

(($prop & $bitmask)) ||
[ -n "$prop" ] && (($prop & $bitmask)) ||
continue

p="$(readlink -e "$i")"

while [ "$p" != "$SYSFS_PATH"/devices ]; do
if [ -f "$p"/modalias ]; then
alias=
readline alias "$p"/modalias
guess_modalias "$alias"

[ -z "$alias" ] ||
guess_modalias "$alias"
fi
p="${p%/*}"
done
Expand Down

2 comments on commit 7b1f1a8

@Vedingrot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@legionus, is it possible?

@legionus
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@legionus, is it possible?

The sysfs is not a real filesystem and there can be weirdness in it. The readline() function appeared because in some version of the kernel there was a line in modalias without a newline. Now I faced[1] another strange situation where the raid uuid was empty, which I have never seen before. So I decided to reassure myself and add checks in case a similar problem occurs in other places reading from sysfs.

[1] https://bugzilla.altlinux.org/51073

Please sign in to comment.