git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Max Kirillov <max@max630.net>
To: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
Cc: Max Kirillov <max@max630.net>, Junio C Hamano <gitster@pobox.com>,
	git@vger.kernel.org, Karthik Nayak <karthik.188@gmail.com>,
	Christian Couder <christian.couder@gmail.com>
Subject: Re: [PATCH] strtoul_ui: actually report error in case of negative input
Date: Mon, 14 Sep 2015 23:26:47 +0300	[thread overview]
Message-ID: <20150914202647.GA7806@wheezy.local> (raw)
In-Reply-To: <vpqr3m1seap.fsf@anie.imag.fr>

On Mon, Sep 14, 2015 at 08:30:54AM +0200, Matthieu Moy wrote:
>> Fix it by changing the last check to trigger earlier, as soon as it
>> becomes bigger than INT_MAX.
> 
> What if the value is actually greater than INT_MAX? The function is
> returning an unsigned long (64 bits on 64bits architectures), and your
> version is restricting it to integers smaller than 2^31, right?

the return type of the function is "int", so this is not
going to work anyway.

As I mentioned, some negative values are still accepted
as coresponding mod 2**32 positive numbers (-3221225472 as
1073741824), so there really is room for improvement, but it
cannot be accomplished just by examining strtoul output.

I saw in the list archives an attempt to abandon the
function in favor of more accurate parser [1], but seems
like it did not make it into the project.

[1] http://thread.gmane.org/gmane.comp.version-control.git/265635

-- 
Max

  reply	other threads:[~2015-09-14 20:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-13 22:00 [PATCH] strtoul_ui: actually report error in case of negative input Max Kirillov
2015-09-14  6:30 ` Matthieu Moy
2015-09-14 20:26   ` Max Kirillov [this message]
2015-09-15  6:50     ` Matthieu Moy
2015-09-16  1:17       ` Junio C Hamano
2015-09-16  4:20       ` Max Kirillov
2015-09-16  6:08         ` Matthieu Moy

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=20150914202647.GA7806@wheezy.local \
    --to=max@max630.net \
    --cc=Matthieu.Moy@grenoble-inp.fr \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=karthik.188@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 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).