]> granicus.if.org Git - strace/commitdiff
x32: fix decoding of 3rd argument of preadv* and pwritev* syscalls
authorEugene Syromyatnikov <evgsyr@gmail.com>
Mon, 19 Dec 2016 22:13:21 +0000 (01:13 +0300)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 20 Dec 2016 03:35:03 +0000 (03:35 +0000)
In x32 personality these syscalls use compat type for the 3rd argument,
therefore it has to be truncated there.

* io.c (do_preadv, do_pwritev): Truncate tcp->u_arg[2] using
widen_to_ulong.

io.c

diff --git a/io.c b/io.c
index 53419ed81d0d783c6a0a0c6f34e2e2b1b85cb0ba..713a1ce4f8b708688d2fa706b36bf6901be25ec7 100644 (file)
--- a/io.c
+++ b/io.c
@@ -222,10 +222,12 @@ do_preadv(struct tcb *tcp, const int flags_arg)
                printfd(tcp, tcp->u_arg[0]);
                tprints(", ");
        } else {
-               tprint_iov_upto(tcp, tcp->u_arg[2], tcp->u_arg[1],
+               unsigned long len = widen_to_ulong(tcp->u_arg[2]);
+
+               tprint_iov_upto(tcp, len, tcp->u_arg[1],
                                syserror(tcp) ? IOV_DECODE_ADDR :
                                IOV_DECODE_STR, tcp->u_rval);
-               tprintf(", %lu, ", tcp->u_arg[2]);
+               tprintf(", %lu, ", len);
                print_lld_from_low_high_val(tcp, 3);
                if (flags_arg >= 0) {
                        tprints(", ");
@@ -248,10 +250,12 @@ SYS_FUNC(preadv2)
 static int
 do_pwritev(struct tcb *tcp, const int flags_arg)
 {
+       unsigned long len = widen_to_ulong(tcp->u_arg[2]);
+
        printfd(tcp, tcp->u_arg[0]);
        tprints(", ");
-       tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], IOV_DECODE_STR);
-       tprintf(", %lu, ", tcp->u_arg[2]);
+       tprint_iov(tcp, len, tcp->u_arg[1], IOV_DECODE_STR);
+       tprintf(", %lu, ", len);
        print_lld_from_low_high_val(tcp, 3);
        if (flags_arg >= 0) {
                tprints(", ");