]> granicus.if.org Git - strace/blobdiff - io.c
Fix printing of unreadable struct iovec
[strace] / io.c
diff --git a/io.c b/io.c
index 2075d201d33b8da1fc14b07c0e32187bbbd6b545..aac93eaecfa55bb6c50aa7075dc18321eb552256 100644 (file)
--- a/io.c
+++ b/io.c
@@ -86,17 +86,23 @@ tprint_iov_upto(struct tcb *tcp, unsigned long len, unsigned long addr, int deco
        } else {
                abbrev_end = end;
        }
-       tprints("[");
+       if (addr >= abbrev_end) {
+               tprints("[...]");
+               return;
+       }
        for (cur = addr; cur < end; cur += sizeof_iov) {
-               if (cur > addr)
+               if (cur > addr) {
                        tprints(", ");
-               if (cur >= abbrev_end) {
-                       tprints("...");
-                       break;
+                       if (cur >= abbrev_end) {
+                               tprints("...");
+                               break;
+                       }
                }
                if (umove_ulong_array_or_printaddr(tcp, cur, iov,
                                                   ARRAY_SIZE(iov)))
                        break;
+               if (cur <= addr)
+                       tprints("[");
                tprints("{");
                if (decode_iov) {
                        unsigned long len = iov[1];
@@ -108,7 +114,8 @@ tprint_iov_upto(struct tcb *tcp, unsigned long len, unsigned long addr, int deco
                        printaddr(iov[0]);
                tprintf(", %lu}", iov[1]);
        }
-       tprints("]");
+       if (cur > addr)
+               tprints("]");
 }
 
 void