]> granicus.if.org Git - strace/blobdiff - wait.c
Robustify mpers.awk against invalid input
[strace] / wait.c
diff --git a/wait.c b/wait.c
index d2eb36d14afb5ed36fefabccabc9a6a234738c04..2e495dbf94117a5acf861a28eecff4a5a7b8c35b 100644 (file)
--- a/wait.c
+++ b/wait.c
@@ -2,16 +2,6 @@
 
 #include <sys/wait.h>
 
-#ifndef __WNOTHREAD
-# define __WNOTHREAD   0x20000000
-#endif
-#ifndef __WALL
-# define __WALL                0x40000000
-#endif
-#ifndef __WCLONE
-# define __WCLONE      0x80000000
-#endif
-
 #include "xlat/wait4_options.h"
 
 #if !defined WCOREFLAG && defined WCOREFLG
@@ -108,13 +98,9 @@ printwaitn(struct tcb *tcp, int n, int bitness)
                tprintf("%d, ", pid);
        } else {
                /* status */
-               if (!tcp->u_arg[1])
-                       tprints("NULL");
-               else if (syserror(tcp) || tcp->u_rval == 0)
-                       tprintf("%#lx", tcp->u_arg[1]);
-               else if (umove(tcp, tcp->u_arg[1], &status) < 0)
-                       tprints("[?]");
-               else
+               if (tcp->u_rval == 0)
+                       printaddr(tcp->u_arg[1]);
+               else if (!umove_or_printaddr(tcp, tcp->u_arg[1], &status))
                        printstatus(status);
                /* options */
                tprints(", ");
@@ -122,9 +108,7 @@ printwaitn(struct tcb *tcp, int n, int bitness)
                if (n == 4) {
                        tprints(", ");
                        /* usage */
-                       if (!tcp->u_arg[3])
-                               tprints("NULL");
-                       else if (tcp->u_rval > 0) {
+                       if (tcp->u_rval > 0) {
 #ifdef ALPHA
                                if (bitness)
                                        printrusage32(tcp, tcp->u_arg[3]);
@@ -133,7 +117,7 @@ printwaitn(struct tcb *tcp, int n, int bitness)
                                        printrusage(tcp, tcp->u_arg[3]);
                        }
                        else
-                               tprintf("%#lx", tcp->u_arg[3]);
+                               printaddr(tcp->u_arg[3]);
                }
        }
        return 0;
@@ -163,8 +147,7 @@ SYS_FUNC(waitid)
        if (entering(tcp)) {
                printxval(waitid_types, tcp->u_arg[0], "P_???");
                tprintf(", %ld, ", tcp->u_arg[1]);
-       }
-       else {
+       } else {
                /* siginfo */
                printsiginfo_at(tcp, tcp->u_arg[2]);
                /* options */
@@ -173,12 +156,7 @@ SYS_FUNC(waitid)
                if (tcp->s_ent->nargs > 4) {
                        /* usage */
                        tprints(", ");
-                       if (!tcp->u_arg[4])
-                               tprints("NULL");
-                       else if (tcp->u_error)
-                               tprintf("%#lx", tcp->u_arg[4]);
-                       else
-                               printrusage(tcp, tcp->u_arg[4]);
+                       printrusage(tcp, tcp->u_arg[4]);
                }
        }
        return 0;