]> granicus.if.org Git - strace/commitdiff
Fix readlink result display - was printing bogus "..." semi-randomly
authorDenys Vlasenko <vda.linux@googlemail.com>
Fri, 27 Jan 2012 16:24:26 +0000 (17:24 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 27 Jan 2012 16:26:29 +0000 (17:26 +0100)
* file.c (decode_readlink): Use printstr() instead of printpathn().

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
file.c

diff --git a/file.c b/file.c
index 343f64a5c16537824046cd73ebf08d379bccc700..b2567c5b63906957df4702e5c8ce0a7886efe2e2 100644 (file)
--- a/file.c
+++ b/file.c
@@ -2048,7 +2048,14 @@ decode_readlink(struct tcb *tcp, int offset)
                if (syserror(tcp))
                        tprintf("%#lx", tcp->u_arg[offset + 1]);
                else
-                       printpathn(tcp, tcp->u_arg[offset + 1], tcp->u_rval);
+                       /* Used to use printpathn(), but readlink
+                        * neither includes NUL in the returned count,
+                        * nor actually writes it into memory.
+                        * printpathn() would decide on printing
+                        * "..." continuation based on garbage
+                        * past return buffer's end.
+                        */
+                       printstr(tcp, tcp->u_arg[offset + 1], tcp->u_rval);
                tprintf(", %lu", tcp->u_arg[offset + 2]);
        }
        return 0;