diff options
author | Denys Vlasenko <dvlasenk@redhat.com> | 2013-11-11 12:24:29 +0100 |
---|---|---|
committer | Denys Vlasenko <dvlasenk@redhat.com> | 2013-11-11 12:24:29 +0100 |
commit | ab24d5182847b52095efb129bbd47dfdc1f21662 (patch) | |
tree | c9ebcd3f1530c30bb87c4a89bfa1a528c293a49c | |
parent | 64778cbfa62d9584c59d3a48b69ba1ebf8bd24e9 (diff) | |
download | strace-ab24d5182847b52095efb129bbd47dfdc1f21662.tar.gz strace-ab24d5182847b52095efb129bbd47dfdc1f21662.tar.bz2 strace-ab24d5182847b52095efb129bbd47dfdc1f21662.tar.xz |
sys_io_submit: stop traversing iocb vector after first failure.
The program may use a very large nr but supply either outright
invalid iocbpp[], or one with far fewer elements than nr.
We used to try reading iocbpp[i] until i == nr.
With this change, we stop on the first failure.
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
-rw-r--r-- | desc.c | 36 |
1 files changed, 18 insertions, 18 deletions
@@ -894,29 +894,30 @@ print_common_flags(struct iocb *iocb) int sys_io_submit(struct tcb *tcp) { - long nr; if (entering(tcp)) { - tprintf("%lu, %ld, ", tcp->u_arg[0], tcp->u_arg[1]); - nr = tcp->u_arg[1]; - /* and if nr is negative? */ - if (nr == 0) - tprints("{}"); - else { #ifdef HAVE_LIBAIO_H + long nr = tcp->u_arg[1]; + /* if nr <= 0, we end up printing just "{}" */ + tprintf("%lu, %ld, {", tcp->u_arg[0], tcp->u_arg[1]); + { long i; - struct iocb *iocbp, **iocbs = (void *)tcp->u_arg[2]; + struct iocb **iocbs = (void *)tcp->u_arg[2]; for (i = 0; i < nr; i++, iocbs++) { enum iocb_sub sub; + struct iocb *iocbp; struct iocb iocb; - if (i == 0) - tprints("{"); - else + if (i) tprints(", "); - if (umove(tcp, (unsigned long)iocbs, &iocbp) || - umove(tcp, (unsigned long)iocbp, &iocb)) { - tprints("{...}"); + if (umove(tcp, (unsigned long)iocbs, &iocbp)) { + tprintf("%#lx", (unsigned long)iocbs); + /* No point in trying to read iocbs+1 etc */ + /* (nr can be ridiculously large): */ + break; + } + if (umove(tcp, (unsigned long)iocbp, &iocb)) { + tprintf("{%#lx}", (unsigned long)iocbp); continue; } tprints("{"); @@ -964,13 +965,12 @@ sys_io_submit(struct tcb *tcp) } tprints("}"); } - if (i) - tprints("}"); + } + tprints("}"); #else #warning "libaio.h is not available => no io_submit decoding" - tprintf("%#lx", tcp->u_arg[2]); + tprintf("%lu, %ld, %#lx", tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]); #endif - } } return 0; } |