summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8f14825)
raw | patch | inline | side by side (parent: 8f14825)
author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | |
Sun, 21 Dec 2008 01:28:48 +0000 (02:28 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 21 Dec 2008 09:48:26 +0000 (01:48 -0800) |
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>
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>
fast-import.c | patch | blob | history |
diff --git a/fast-import.c b/fast-import.c
index 171d1783399c970136d55cf86fdb78b5c4edce65..a6bce661963812691503116e8d61d9ef90f96526 100644 (file)
--- a/fast-import.c
+++ b/fast-import.c
{
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;
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);