]> granicus.if.org Git - strace/commitdiff
evdev.c: fix decoding of struct input_keymap_entry
authorDmitry V. Levin <ldv@altlinux.org>
Fri, 27 May 2016 00:41:34 +0000 (00:41 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sat, 28 May 2016 00:56:47 +0000 (00:56 +0000)
* evdev.c (keycode_V2_ioctl): Use umove_or_printaddr.

evdev.c

diff --git a/evdev.c b/evdev.c
index 4619ecb11369bf041560d99fd18ffb6cdcea14da..1ffad841d7c17ed01d23f4cdf5c6a14fc34b844e 100644 (file)
--- a/evdev.c
+++ b/evdev.c
@@ -195,21 +195,22 @@ keycode_ioctl(struct tcb *tcp, long arg)
 static int
 keycode_V2_ioctl(struct tcb *tcp, long arg)
 {
+       tprints(", ");
+
        struct input_keymap_entry ike;
 
-       if (!arg) {
-               tprints(", NULL");
+       if (umove_or_printaddr(tcp, arg, &ike))
                return 1;
-       }
 
-       if (!verbose(tcp) || umove(tcp, arg, &ike) < 0)
-               return 0;
+       tprintf("{flags=%" PRIu8
+               ", len=%" PRIu8 ", ",
+               ike.flags,
+               ike.len);
 
-       tprintf(", {flags=%" PRIu8 ", len=%" PRIu8, ike.flags, ike.len);
        if (!abbrev(tcp)) {
                unsigned int i;
 
-               tprintf("index=%" PRIu16 ", keycode=", ike.index);
+               tprintf("index=%" PRIu16 ", keycode=", ike.index);
                printxval(evdev_keycode, ike.keycode, "KEY_???");
                tprints(", scancode=[");
                for (i = 0; i < ARRAY_SIZE(ike.scancode); i++) {
@@ -217,10 +218,13 @@ keycode_V2_ioctl(struct tcb *tcp, long arg)
                                tprints(", ");
                        tprintf("%" PRIx8, ike.scancode[i]);
                }
-               tprints("]}");
+               tprints("]");
        } else {
-               tprints(", ...}");
+               tprints("...");
        }
+
+       tprints("}");
+
        return 1;
 }
 # endif /* EVIOCGKEYCODE_V2 */