]> granicus.if.org Git - strace/blobdiff - time.c
Robustify mpers.awk against invalid input
[strace] / time.c
diff --git a/time.c b/time.c
index 209cb8763568a551d9403eaf014bda256886b8e8..c98862d8cf2453df0c97eda4f8fc0161f5a22e77 100644 (file)
--- a/time.c
+++ b/time.c
 #include <signal.h>
 #include <sys/timex.h>
 
-#ifndef UTIME_NOW
-#define UTIME_NOW ((1l << 30) - 1l)
-#endif
-#ifndef UTIME_OMIT
-#define UTIME_OMIT ((1l << 30) - 2l)
-#endif
-
-#if SUPPORTED_PERSONALITIES > 1
-# if defined X86_64 || defined X32
-#  define current_time_t_is_compat (current_personality == 1)
-# else
-#  define current_time_t_is_compat (current_wordsize == 4)
-# endif
-#else
-# define current_time_t_is_compat 0
-#endif
-
-struct timeval32
-{
-       u_int32_t tv_sec, tv_usec;
-};
-
-void
-printtv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness, int special)
-{
-       char buf[TIMEVAL_TEXT_BUFSIZE];
-       sprinttv(buf, tcp, addr, bitness, special);
-       tprints(buf);
-}
-
-static char *
-do_sprinttv(char *buf, const uintmax_t sec, const uintmax_t usec,
-           const int special)
-{
-       if (special) {
-               switch (usec) {
-                       case UTIME_NOW:
-                               return stpcpy(buf, "UTIME_NOW");
-                       case UTIME_OMIT:
-                               return stpcpy(buf, "UTIME_OMIT");
-               }
-       }
-       return buf + sprintf(buf, "{%ju, %ju}", sec, usec);
-}
-
-char *
-sprinttv(char *buf, struct tcb *tcp, long addr, enum bitness_t bitness, int special)
-{
-       if (addr == 0)
-               return stpcpy(buf, "NULL");
-
-       if (!verbose(tcp) || (exiting(tcp) && syserror(tcp)))
-               return buf + sprintf(buf, "%#lx", addr);
-
-       if (bitness == BITNESS_32 || current_time_t_is_compat)
-       {
-               struct timeval32 tv;
-
-               if (umove(tcp, addr, &tv) >= 0)
-                       return do_sprinttv(buf, tv.tv_sec, tv.tv_usec, special);
-       } else {
-               struct timeval tv;
-
-               if (umove(tcp, addr, &tv) >= 0)
-                       return do_sprinttv(buf, tv.tv_sec, tv.tv_usec, special);
-       }
-
-       return buf + sprintf(buf, "%#lx", addr);
-}
-
-void
-sprint_timespec(char *buf, struct tcb *tcp, long addr)
-{
-       if (addr == 0)
-               strcpy(buf, "NULL");
-       else if (!verbose(tcp))
-               sprintf(buf, "%#lx", addr);
-       else {
-               int rc;
-
-#if SUPPORTED_PERSONALITIES > 1
-               if (current_time_t_is_compat) {
-                       struct timeval32 tv;
-
-                       rc = umove(tcp, addr, &tv);
-                       if (rc >= 0)
-                               sprintf(buf, "{%u, %u}",
-                                       tv.tv_sec, tv.tv_usec);
-               } else
-#endif
-               {
-                       struct timespec ts;
-
-                       rc = umove(tcp, addr, &ts);
-                       if (rc >= 0)
-                               sprintf(buf, "{%ju, %ju}",
-                                       (uintmax_t) ts.tv_sec,
-                                       (uintmax_t) ts.tv_nsec);
-               }
-               if (rc < 0)
-                       strcpy(buf, "{...}");
-       }
-}
-
 static void
 print_timezone(struct tcb *tcp, const long addr)
 {