From: Junio C Hamano <gitster@pobox.com>
To: Ryan Flynn <parseerror@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] fix potential infinite loop given large unsigned integer
Date: Sat, 08 Aug 2009 23:19:18 -0700 [thread overview]
Message-ID: <7vy6pta4rd.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <a3f15ee60908082141l7b2134cg5ddcef17c45fc888@mail.gmail.com> (Ryan Flynn's message of "Sun\, 9 Aug 2009 00\:41\:21 -0400")
Ryan Flynn <parseerror@gmail.com> writes:
> given n, tried to find i greater than n via i=1, iterate i *= 10.
> given n sufficiently close to UINT_MAX this will overflow; which can
> produce i==0, which results in an infinite loop. iteratively dividing
> n /= 10 does not have this problem, and though division is slower than
> multiplication this only runs once per `git format-patch
> --cover-letter`
>
> Signed-off-by: pizza <parseerror@gmail.com>
Pizza?
This is somewhat amusing.
- digits_in_number() is called only with opt->total that is "int";
- opt->total is the total number of patches.
- the return value is used like this:
sprintf(buf, "%0*d", digits_in_number(opt->total), opt->nr);
and opt->nr runs from 1 to opt->total; the use of "d" would be already
wrong anyway even if you computed digits_in_number() correctly.
Perhaps we should get rid of this function altogether?
next prev parent reply other threads:[~2009-08-09 6:19 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-09 4:41 [PATCH] fix potential infinite loop given large unsigned integer Ryan Flynn
2009-08-09 6:19 ` Junio C Hamano [this message]
2009-08-09 7:38 ` Junio C Hamano
2009-08-09 12:25 ` Erik Faye-Lund
2009-08-10 5:24 ` Christian Couder
2009-08-10 11:12 ` Erik Faye-Lund
2009-08-10 12:24 ` Johannes Schindelin
2009-08-10 16:14 ` Ryan Flynn
2009-08-10 16:17 ` Ryan Flynn
2009-08-10 16:53 ` Johannes Schindelin
2009-08-11 0:55 ` Jeff Epler
2009-08-10 0:23 ` Ryan Flynn
2009-08-10 18:19 ` Tony Finch
2009-08-09 23:16 ` Ryan Flynn
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=7vy6pta4rd.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=parseerror@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.