]> granicus.if.org Git - strace/commitdiff
evdev: fix decoding of bit sets
authorZhibin Li <08826794brmt@gmail.com>
Wed, 1 Aug 2018 09:53:57 +0000 (17:53 +0800)
committerDmitry V. Levin <ldv@altlinux.org>
Sun, 19 Aug 2018 10:26:18 +0000 (10:26 +0000)
According to drivers/input/evdev.c:bits_to_user(),
the Linux kernel returns the number of bytes, not bits.

* evdev.c (decode_bitset_): Treat syscall return value as the number
of bytes.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
Fixes: v4.10~89 "Add decoding for evdev ioctls"
evdev.c

diff --git a/evdev.c b/evdev.c
index 7ca15c9dd1e5b4f2b23bb75093b5533078da1ecc..3c1aaa8e2cf8f2db77ae034ae238d067d30a7a1d 100644 (file)
--- a/evdev.c
+++ b/evdev.c
@@ -171,10 +171,10 @@ decode_bitset_(struct tcb *const tcp, const kernel_ulong_t arg,
        tprints(", ");
 
        unsigned int size;
-       if ((kernel_ulong_t) tcp->u_rval > max_nr)
+       if ((kernel_ulong_t) tcp->u_rval > max_nr / 8)
                size = max_nr;
        else
-               size = tcp->u_rval;
+               size = tcp->u_rval * 8;
        char decoded_arg[size];
 
        if (umove_or_printaddr(tcp, arg, &decoded_arg))