diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-03-14 14:25:44 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-03-14 14:25:44 -0700 |
commit | 3c83b080e4dce42d0f48d28b03691ae1ac0dcde3 (patch) | |
tree | 0f8ab0d53aff78a10ea43439c20c02500c733388 /pretty.c | |
parent | b37f81b7b676fe7ede3fa171535593337a8911c8 (diff) | |
parent | 3f419d45ef0dfc33dc301d9ae4737043c091291a (diff) | |
download | git-3c83b080e4dce42d0f48d28b03691ae1ac0dcde3.tar.gz |
Merge branch 'jk/commit-dates-parsing-fix'
Tighten codepaths that parse timestamps in commit objects.
* 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.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -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); } |