diff mbox series

[2/3] rfkill.c: deal with updated struct size

Message ID 20210206153411.19097-2-markus.theil@tu-ilmenau.de
State New
Headers show
Series [1/3] rfkill: update rfkill.h | expand

Commit Message

Markus Theil Feb. 6, 2021, 3:34 p.m. UTC
Signed-off-by: Markus Theil <markus.theil@tu-ilmenau.de>
---
 rfkill.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/rfkill.c b/rfkill.c
index 8cd81fe..6b5ca2c 100644
--- a/rfkill.c
+++ b/rfkill.c
@@ -45,13 +45,14 @@  static void rfkill_event(void)
 		if (n == 0)
 			continue;
 
+		memset(&event, 0, sizeof(event));
 		len = read(fd, &event, sizeof(event));
 		if (len < 0) {
 			perror("Reading of RFKILL events failed");
 			break;
 		}
 
-		if (len != RFKILL_EVENT_SIZE_V1) {
+		if (len < RFKILL_EVENT_SIZE_V1) {
 			fprintf(stderr, "Wrong size of RFKILL event\n");
 			continue;
 		}
@@ -206,6 +207,7 @@  static int rfkill_list(const char *param)
 	}
 
 	while (1) {
+		memset(&event, 0, sizeof(event));
 		len = read(fd, &event, sizeof(event));
 		if (len < 0) {
 			if (errno == EAGAIN)
@@ -214,7 +216,7 @@  static int rfkill_list(const char *param)
 			break;
 		}
 
-		if (len != RFKILL_EVENT_SIZE_V1) {
+		if (len < RFKILL_EVENT_SIZE_V1) {
 			fprintf(stderr, "Wrong size of RFKILL event\n");
 			continue;
 		}