summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2013-03-20 09:48:44 +0000
committerDmitry V. Levin <ldv@altlinux.org>2013-03-20 14:38:20 +0000
commit2c42f32518e43b1e5ccb00c19010a799be6858d4 (patch)
tree65f5dea56e8ccc0f1ad8b99491e872e37c28739e /io.c
parent3b211d8df0c28490b883fb521329faab384d4520 (diff)
downloadstrace-2c42f32518e43b1e5ccb00c19010a799be6858d4.tar.gz
strace-2c42f32518e43b1e5ccb00c19010a799be6858d4.tar.bz2
strace-2c42f32518e43b1e5ccb00c19010a799be6858d4.tar.xz
Do not use off_t in sendfile decoding
sendfile parser used to decode off_t* parameter as a pointer to host off_t type. With this change, it is decoded as a pointer to target long type. * io.c (print_off_t): New function. (sys_sendfile): Use it. * linux/aarch64/syscallent1.h: Use sys_sendfile64 for sendfile decoding. * linux/tile/syscallent.h: Likewise. * linux/x32/syscallent.h: Likewise. * linux/x86_64/syscallent.h: Likewise. * linux/hppa/syscallent.h: Use sys_sendfile64 for sendfile64 decoding. * linux/metag/syscallent.h: Correct sendfile syscall name. * linux/or1k/syscallent.h: Likewise.
Diffstat (limited to 'io.c')
-rw-r--r--io.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/io.c b/io.c
index 0e9bb32..b7bf832 100644
--- 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;