aboutsummaryrefslogtreecommitdiffstats
path: root/ref-filter.c
diff options
context:
space:
mode:
authorKyle Lippincott <spectral@google.com>2024-08-05 17:10:07 +0000
committerJunio C Hamano <gitster@pobox.com>2024-08-05 10:59:20 -0700
commitb928d57ca9aa7457ec0dee022c1664e8cd606b22 (patch)
tree04bd3817e53f3c9a4d7e7a4fac1740abe1b2c09b /ref-filter.c
parentGit 2.46 (diff)
downloadgit-b928d57ca9aa7457ec0dee022c1664e8cd606b22.tar.gz
git-b928d57ca9aa7457ec0dee022c1664e8cd606b22.zip
set errno=0 before strtoX calls
To detect conversion failure after calls to functions like `strtod`, one can check `errno == ERANGE`. These functions are not guaranteed to set `errno` to `0` on successful conversion, however. Manual manipulation of `errno` can likely be avoided by checking that the output pointer differs from the input pointer, but that's not how other locations, such as parse.c:139, handle this issue; they set errno to 0 prior to executing the function. For every place I could find a strtoX function with an ERANGE check following it, set `errno = 0;` prior to executing the conversion function. Signed-off-by: Kyle Lippincott <spectral@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'ref-filter.c')
-rw-r--r--ref-filter.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/ref-filter.c b/ref-filter.c
index 8c5e673fc0..54880a2497 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -1628,6 +1628,7 @@ static void grab_date(const char *buf, struct atom_value *v, const char *atomnam
timestamp = parse_timestamp(eoemail + 2, &zone, 10);
if (timestamp == TIME_MAX)
goto bad;
+ errno = 0;
tz = strtol(zone, NULL, 10);
if ((tz == LONG_MIN || tz == LONG_MAX) && errno == ERANGE)
goto bad;