]> granicus.if.org Git - strace/blobdiff - io.c
Do not use off_t in sendfile decoding
[strace] / io.c
diff --git a/io.c b/io.c
index 0e9bb32de8758814ddbba55a72709d4397bfaa1b..b7bf8327a5a32bef7d27a207235919a84259797a 100644 (file)
--- a/io.c
+++ b/io.c
@@ -250,30 +250,41 @@ sys_pwritev(struct tcb *tcp)
 }
 #endif /* HAVE_SYS_UIO_H */
 
+static void
+print_off_t(struct tcb *tcp, long addr)
+{
+       unsigned long offset;
+
+       if (!addr) {
+               tprints("NULL");
+               return;
+       }
+
+#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
+       if (current_wordsize == 4) {
+               uint32_t off;
+
+               if (umove(tcp, addr, &off) < 0)
+                       tprintf("%#lx", addr);
+               else
+                       tprintf("[%u]", off);
+       } else
+#endif
+       if (umove(tcp, addr, &offset) < 0)
+               tprintf("%#lx", addr);
+       else
+               tprintf("[%lu]", offset);
+}
+
 int
 sys_sendfile(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               off_t offset;
-
                printfd(tcp, tcp->u_arg[0]);
                tprints(", ");
                printfd(tcp, tcp->u_arg[1]);
                tprints(", ");
-               if (!tcp->u_arg[2])
-                       tprints("NULL");
-//FIXME: obviously bogus.
-//Probably should use explicit long.
-//Arches with long long offset param should use
-//sys_sendfile64, not this fn.
-               else if (umove(tcp, tcp->u_arg[2], &offset) < 0)
-                       tprintf("%#lx", tcp->u_arg[2]);
-               else
-#ifdef HAVE_LONG_LONG_OFF_T
-                       tprintf("[%llu]", offset);
-#else
-                       tprintf("[%lu]", offset);
-#endif
+               print_off_t(tcp, tcp->u_arg[2]);
                tprintf(", %lu", tcp->u_arg[3]);
        }
        return 0;