]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
rfkill: use back and forward compatible test
authorSami Kerola <kerolasa@iki.fi>
Sat, 1 Jul 2017 08:15:12 +0000 (09:15 +0100)
committerSami Kerola <kerolasa@iki.fi>
Wed, 30 Aug 2017 19:32:49 +0000 (20:32 +0100)
The rfkill_event struct might grow in future, so ensure the read sizes are
at least the minimum, and allow it to be more.

Reference: https://github.com/torvalds/linux/blob/master/include/uapi/linux/rfkill.h#L90-L102
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sys-utils/rfkill.c

index 7d059a0ffeb3fa2d210456ea9c8cfae43f2d76e4..2f744ecf62f37fc57c4bd8cc80455790dec580fc 100644 (file)
@@ -170,8 +170,8 @@ static int rfkill_event(void)
                        break;
                }
 
-               if (len != RFKILL_EVENT_SIZE_V1) {
-                       warnx(_("wrong size of rfkill event: %zu != %d"), len, RFKILL_EVENT_SIZE_V1);
+               if (len < RFKILL_EVENT_SIZE_V1) {
+                       warnx(_("wrong size of rfkill event: %zu < %d"), len, RFKILL_EVENT_SIZE_V1);
                        ret = 1;
                        continue;
                }
@@ -348,8 +348,8 @@ static int rfkill_list(struct control const *const ctrl, const char *param)
                        break;
                }
 
-               if (len != RFKILL_EVENT_SIZE_V1) {
-                       warnx(_("wrong size of rfkill event: %zu != %d"), len, RFKILL_EVENT_SIZE_V1);
+               if (len < RFKILL_EVENT_SIZE_V1) {
+                       warnx(_("wrong size of rfkill event: %zu < %d"), len, RFKILL_EVENT_SIZE_V1);
                        continue;
                }