diff options
author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | 2008-12-21 02:28:48 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-12-21 01:48:26 -0800 |
commit | c55fae43c4e10e2779e4fb7d70d6f6e4a7645a63 (patch) | |
tree | a2bb72cf0cd0d027a050276dcf2b77aee1986b4b /fast-import.c | |
parent | 8f1482536ad680fcd738158e76e254a534f2e690 (diff) | |
download | git-c55fae43c4e10e2779e4fb7d70d6f6e4a7645a63.tar.gz |
fast-import.c: stricter strtoul check, silence compiler warning
Store the return value of strtoul() in order to avoid compiler
warnings on Ubuntu 8.10.
Also check errno after each call, which is the only way to notice
an overflow without making ULONG_MAX an illegal date.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fast-import.c')
-rw-r--r-- | fast-import.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/fast-import.c b/fast-import.c index 171d178339..a6bce66196 100644 --- a/fast-import.c +++ b/fast-import.c @@ -1748,9 +1748,12 @@ static int validate_raw_date(const char *src, char *result, int maxlen) { const char *orig_src = src; char *endp, sign; + unsigned long date; - strtoul(src, &endp, 10); - if (endp == src || *endp != ' ') + errno = 0; + + date = strtoul(src, &endp, 10); + if (errno || endp == src || *endp != ' ') return -1; src = endp + 1; @@ -1758,8 +1761,8 @@ static int validate_raw_date(const char *src, char *result, int maxlen) return -1; sign = *src; - strtoul(src + 1, &endp, 10); - if (endp == src || *endp || (endp - orig_src) >= maxlen) + date = strtoul(src + 1, &endp, 10); + if (errno || endp == src || *endp || (endp - orig_src) >= maxlen) return -1; strcpy(result, orig_src); |