]> granicus.if.org Git - strace/blobdiff - times.c
Robustify mpers.awk against invalid input
[strace] / times.c
diff --git a/times.c b/times.c
index 0301c9f9520c362fa2b078418e32bd32bfb1ac45..be23950126ad16c809e38ddddd3669ef7225c736 100644 (file)
--- a/times.c
+++ b/times.c
@@ -1,19 +1,29 @@
 #include "defs.h"
+#include DEF_MPERS_TYPE(tms_t)
 #include <sys/times.h>
+typedef struct tms tms_t;
+#include MPERS_DEFS
 
 SYS_FUNC(times)
 {
-       struct tms tbuf;
+       tms_t tbuf;
 
-       if (exiting(tcp)) {
-               if (!umove_or_printaddr(tcp, tcp->u_arg[0], &tbuf)) {
-                       tprintf("{tms_utime=%llu, tms_stime=%llu, ",
-                               (unsigned long long) tbuf.tms_utime,
-                               (unsigned long long) tbuf.tms_stime);
-                       tprintf("tms_cutime=%llu, tms_cstime=%llu}",
-                               (unsigned long long) tbuf.tms_cutime,
-                               (unsigned long long) tbuf.tms_cstime);
-               }
+       if (entering(tcp))
+               return 0;
+
+       if (!umove_or_printaddr(tcp, tcp->u_arg[0], &tbuf)) {
+               tprintf("{tms_utime=%Lu, tms_stime=%Lu, ",
+                       (unsigned long long) tbuf.tms_utime,
+                       (unsigned long long) tbuf.tms_stime);
+               tprintf("tms_cutime=%Lu, tms_cstime=%Lu}",
+                       (unsigned long long) tbuf.tms_cutime,
+                       (unsigned long long) tbuf.tms_cstime);
        }
-       return 0;
+
+       return syserror(tcp) ? RVAL_DECIMAL :
+#if defined(RVAL_LUDECIMAL) && !defined(IN_MPERS)
+                              RVAL_LUDECIMAL;
+#else
+                              RVAL_UDECIMAL;
+#endif
 }