From 2c42f32518e43b1e5ccb00c19010a799be6858d4 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Wed, 20 Mar 2013 09:48:44 +0000 Subject: 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. --- io.c | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) (limited to 'io.c') 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; -- cgit v1.2.3