]> granicus.if.org Git - strace/commitdiff
umovestr result may have no NUL, use "%.*s" instead of "%s" to print it
authorDenys Vlasenko <vda.linux@googlemail.com>
Fri, 20 Jan 2012 10:52:12 +0000 (11:52 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 20 Jan 2012 10:52:12 +0000 (11:52 +0100)
* system.c (sys_mount): Be careful when printing umovestr result,
it may have no terminating NUL.
(sys_sysmips): Likewise.

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

index 8b7d6b3a052de144b71336e588ab04f273e27a5a..58c4bd7ebd9b2d02c3b056f8dc91d420c288bd60 100644 (file)
--- a/system.c
+++ b/system.c
@@ -513,7 +513,7 @@ sys_mount(struct tcb *tcp)
                                tcp->u_arg[0],  sizeof type, type) < 0) {
                        tprintf("OLDTYPE:#%lx", tcp->u_arg[0]);
                } else {
-                       tprintf("\"%s\", ", type);
+                       tprintf("\"%.4s\", ", type);
                }
                printstr(tcp, tcp->u_arg[1], -1);
                tprints(", ");
@@ -1437,11 +1437,11 @@ sys_mount(struct tcb *tcp)
                   for all SVR4's? */
                if (tcp->u_arg[2] & (MS_FSS | MS_DATA)) {
                        if (umovestr(tcp, tcp->u_arg[3], FSTYPSZ, fstyp) < 0) {
-                               *fstyp = 0;
+                               fstyp[0] = '\0';
                                tprintf(", %ld", tcp->u_arg[3]);
                        }
                        else
-                               tprintf(", \"%s\"", fstyp);
+                               tprintf(", \"%.*s\"", (int)FSTYPSZ, fstyp);
                }
                if (tcp->u_arg[2] & MS_DATA) {
                        tprints(", ");
@@ -2317,7 +2317,7 @@ int sys_sysmips(struct tcb *tcp)
                        if (umovestr(tcp, tcp->u_arg[1], (__NEW_UTS_LEN + 1), nodename) < 0)
                                tprintf(", %#lx", tcp->u_arg[1]);
                        else
-                               tprintf(", \"%s\"", nodename);
+                               tprintf(", \"%.*s\"", (int)(__NEW_UTS_LEN + 1), nodename);
                } else if (tcp->u_arg[0] == MIPS_ATOMIC_SET) {
                        tprintf(", %#lx, 0x%lx", tcp->u_arg[1], tcp->u_arg[2]);
                } else if (tcp->u_arg[0] == MIPS_FIXADE) {