[gnome-settings-daemon/benzea/fix-read-len-check] rfkill: Fix rfkill event read length check
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/benzea/fix-read-len-check] rfkill: Fix rfkill event read length check
- Date: Wed, 14 Apr 2021 10:12:07 +0000 (UTC)
commit f6ce8d3f1a70a0e63699b00905921841f0474bb2
Author: Benjamin Berg <bberg redhat com>
Date: Wed Apr 14 11:55:51 2021 +0200
rfkill: Fix rfkill event read length check
The kernel may return a short read for rfkill events in case it is using
an older API version while g-s-d was compiled using the newer struct. As
this is perfectly valid, we need to check the read length against
RFKILL_EVENT_SIZE_V1 rather than the size of the struct.
plugins/rfkill/rfkill-glib.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/plugins/rfkill/rfkill-glib.c b/plugins/rfkill/rfkill-glib.c
index 22309dce..e799174a 100644
--- a/plugins/rfkill/rfkill-glib.c
+++ b/plugins/rfkill/rfkill-glib.c
@@ -342,7 +342,7 @@ event_cb (GIOChannel *source,
if (condition & G_IO_IN) {
GIOStatus status;
- struct rfkill_event event;
+ struct rfkill_event event = { 0 };
gsize read;
status = g_io_channel_read_chars (source,
@@ -351,7 +351,7 @@ event_cb (GIOChannel *source,
&read,
NULL);
- while (status == G_IO_STATUS_NORMAL && read == sizeof(event)) {
+ while (status == G_IO_STATUS_NORMAL && read >= RFKILL_EVENT_SIZE_V1) {
struct rfkill_event *event_ptr;
print_event (&event);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]