rfkill: Fix reading from rfkill socket
authorBenjamin Berg <bberg@redhat.com>
Mon, 3 May 2021 13:12:10 +0000 (15:12 +0200)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:35 +0000 (19:08 +0530)
commit368f8cfb5a91e8abff51123ec82289094c63837d
tree44ceb72a78e27c8d991e67146bd81f8bcc86884f
parent8e00187fb3fff4ff4ff80d6e2bb0ea2ba4668245
rfkill: Fix reading from rfkill socket

The kernel will always send exactly one event, but the size of the
passed struct will depend on the length of the submitted read() and the
kernel version. i.e. the interface can be extended and we need to expect
for a read to be longer than expected if we ask for it.

Fix this by only requesting the needed length and explicitly check the
length against the V1 version of the structure to make the code a bit
more future proof in case the internal copy of the struct is updated to
contain new fields.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
src/rfkill.c