From: Andreas Schwab <schwab@linux-m68k.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: Erik Bray <erik.m.bray@gmail.com>,
git@vger.kernel.org,
Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: Timestamp of zero in reflog considered invalid
Date: Tue, 05 Apr 2016 19:41:58 +0200 [thread overview]
Message-ID: <87r3ek3qc9.fsf@linux-m68k.org> (raw)
In-Reply-To: <xmqqbn5o2gv1.fsf@gitster.mtv.corp.google.com> (Junio C. Hamano's message of "Tue, 05 Apr 2016 08:52:02 -0700")
Junio C Hamano <gitster@pobox.com> writes:
> Checking the value against ULONG_MAX and errno==ERANGE would be an
> improvement. It may be debatable if we should silently ignore an
> entry with an invalid timestamp, but that is a separate issue.
>
> refs.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/refs.c b/refs.c
> index 4e15f60..ff24184 100644
> --- a/refs.c
> +++ b/refs.c
> @@ -3701,7 +3701,8 @@ static int show_one_reflog_ent(struct strbuf *sb, each_reflog_ent_fn fn, void *c
> get_sha1_hex(sb->buf + 41, nsha1) || sb->buf[81] != ' ' ||
> !(email_end = strchr(sb->buf + 82, '>')) ||
> email_end[1] != ' ' ||
> - !(timestamp = strtoul(email_end + 2, &message, 10)) ||
> + ((timestamp = strtoul(email_end + 2, &message, 10)) == ULONG_MAX &&
> + errno == ERANGE) ||
You need to set errno = 0 before calling strtoul, to distinguish the
valid return of ULONG_MAX (which would keep errno intact) and a real
overflow.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
next prev parent reply other threads:[~2016-04-05 17:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-05 11:28 Timestamp of zero in reflog considered invalid Erik Bray
2016-04-05 15:52 ` Junio C Hamano
2016-04-05 17:41 ` Andreas Schwab [this message]
2016-04-06 12:18 ` Johannes Schindelin
2016-04-06 13:20 ` Erik Bray
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r3ek3qc9.fsf@linux-m68k.org \
--to=schwab@linux-m68k.org \
--cc=erik.m.bray@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=johannes.schindelin@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).