diff options
author | Jeff King <peff@peff.net> | 2014-03-07 21:15:01 +0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-03-07 23:53:29 +0400 |
commit | 3f419d45ef0dfc33dc301d9ae4737043c091291a (patch) | |
tree | e72175e8040f851f4e567ad6db3965ce24c13ece /git-compat-util.h | |
parent | 2b15846dbfb31df10a69a4d56ae944a01563bc07 (diff) |
show_ident_date: fix tz range check
Commit 1dca155fe3fa (log: handle integer overflow in
timestamps, 2014-02-24) tried to catch integer overflow
coming from strtol() on the timezone field by comparing against
LONG_MIN/LONG_MAX. However, the intermediate "tz" variable
is an "int", which means it can never be LONG_MAX on LP64
systems; we would truncate the output from strtol before the
comparison.
Clang's -Wtautological-constant-out-of-range-compare notices
this and rightly complains.
Let's instead store the result of strtol in a long, and then
compare it against INT_MIN/INT_MAX. This will catch overflow
from strtol, and also overflow when we pass the result as an
int to show_date.
Reported-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-compat-util.h')
0 files changed, 0 insertions, 0 deletions