summaryrefslogtreecommitdiff
path: root/pretty.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-03-18 21:04:01 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-03-18 21:04:01 (GMT)
commit8aac6c97e81dee53ae7740663128b0296398d6d1 (patch)
treed6977ae7a154fe5ddb272c5e6475eb9fd4467c05 /pretty.c
parenta5aca6e883639ce3a3ad07271032905edc0ac608 (diff)
parent3f419d45ef0dfc33dc301d9ae4737043c091291a (diff)
downloadgit-8aac6c97e81dee53ae7740663128b0296398d6d1.zip
git-8aac6c97e81dee53ae7740663128b0296398d6d1.tar.gz
git-8aac6c97e81dee53ae7740663128b0296398d6d1.tar.bz2
Merge branch 'jk/commit-dates-parsing-fix' into maint
Codepaths that parse timestamps in commit objects have been tightened. * jk/commit-dates-parsing-fix: show_ident_date: fix tz range check log: do not segfault on gmtime errors log: handle integer overflow in timestamps date: check date overflow against time_t fsck: report integer overflow in author timestamps t4212: test bogus timestamps with git-log
Diffstat (limited to 'pretty.c')
-rw-r--r--pretty.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/pretty.c b/pretty.c
index 87db08b..6e266dd 100644
--- a/pretty.c
+++ b/pretty.c
@@ -397,12 +397,18 @@ static const char *show_ident_date(const struct ident_split *ident,
enum date_mode mode)
{
unsigned long date = 0;
- int tz = 0;
+ long tz = 0;
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 >= INT_MAX || tz <= INT_MIN)
+ tz = 0;
+ }
return show_date(date, tz, mode);
}