log: handle integer overflow in timestamps
[gitweb.git] / pretty.c
index acbfceb5fea49e49f5cc8eaef816c4b0a6ffe05a..4da9a682f3bd6f8d5ae40c5eac8af01c87f28496 100644 (file)
--- a/pretty.c
+++ b/pretty.c
@@ -401,8 +401,14 @@ static const char *show_ident_date(const struct ident_split *ident,
 
        if (ident->date_begin && ident->date_end)
                date = strtoul(ident->date_begin, NULL, 10);
-       if (ident->tz_begin && ident->tz_end)
-               tz = strtol(ident->tz_begin, NULL, 10);
+       if (date_overflows(date))
+               date = 0;
+       else {
+               if (ident->tz_begin && ident->tz_end)
+                       tz = strtol(ident->tz_begin, NULL, 10);
+               if (tz == LONG_MAX || tz == LONG_MIN)
+                       tz = 0;
+       }
        return show_date(date, tz, mode);
 }