git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Kristoffer Haugsbakk" <code@khaugsbakk.name>
To: "Rubén Justo" <rjusto@gmail.com>
Cc: "Tiago Pascoal" <tiago@pascoal.net>,
	"Chris Torek" <chris.torek@gmail.com>,
	"Junio C Hamano" <gitster@pobox.com>,
	git@vger.kernel.org
Subject: Re: [PATCH v3 0/2] column: disallow negative padding
Date: Tue, 13 Feb 2024 21:32:32 +0100	[thread overview]
Message-ID: <dc1be818-e793-44f6-98dd-b159e043da28@app.fastmail.com> (raw)
In-Reply-To: <48b96426-9231-4e80-b55d-628dd8847337@gmail.com>

On Tue, Feb 13, 2024, at 20:27, Rubén Justo wrote:
>     * P.D. *
>
>     Thinking about this in a more general way, I've found that this kind
>     of error has hit us several times:
>
>       - 953aa54e1a (pack-objects: clamp negative window size to 0, 2021-05-01)
>       - 6d52b6a5df (pack-objects: clamp negative depth to 0, 2021-05-01)
>
>     Maybe the source of this error is how easy is to forget that
>     OPT_INTEGER can accept negative values (after all, that's what an
>     integer is).
>
>     There are not many users of OPT_INTEGER, and a quick check gives me
>     the impression (maybe wrong...) that many of them do not expect
>     negative values.
>
>     Maybe we should consider having an OPT_INTEGER that fails if the
>     value supplied is negative.  Ideally, some kind of opt-in machinery
>     could be desirable, I think, for example to include/exclude:
>
>     	- negative values
>     	- "0"  ( may not be a desired value )
>     	- "-1" ( may have some special meaning )
>     	- ...
>
>     I'll leave the idea here, just in case it inspires someone.  Thank
>     you.

Thanks to both for providing a wider perspective on guarding against
such bugs.

And this is an excellent point. I don’t know anything about the opt-args
implementation but it would be great to guard against user-supplied
values through the option parsing library.

Cheers

-- 
Kristoffer Haugsbakk


  reply	other threads:[~2024-02-13 20:32 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-09 14:21 git column fails (or crashes) if padding is negative Tiago Pascoal
2024-02-09 16:27 ` Kristoffer Haugsbakk
2024-02-09 17:57   ` Junio C Hamano
2024-02-11 17:08     ` Kristoffer Haugsbakk
2024-02-12 16:37       ` Junio C Hamano
2024-02-09 17:52 ` [PATCH] column: disallow negative padding Kristoffer Haugsbakk
2024-02-09 18:26   ` Kristoffer Haugsbakk
2024-02-10  9:48     ` Chris Torek
2024-02-11 17:10       ` Kristoffer Haugsbakk
2024-02-11 17:55         ` Junio C Hamano
2024-02-11 18:18           ` Kristoffer Haugsbakk
2024-02-11 19:27   ` [PATCH v2] " Kristoffer Haugsbakk
2024-02-11 22:47     ` Rubén Justo
2024-02-11 23:50       ` Rubén Justo
2024-02-12  7:05       ` Kristoffer Haugsbakk
2024-02-12 16:50       ` Kristoffer Haugsbakk
2024-02-12 21:28         ` Rubén Justo
2024-02-13 16:01     ` [PATCH v3 0/2] " Kristoffer Haugsbakk
2024-02-13 16:01       ` [PATCH v3 1/2] " Kristoffer Haugsbakk
2024-02-13 16:01       ` [PATCH v3 2/2] column: guard against " Kristoffer Haugsbakk
2024-02-13 17:06         ` Junio C Hamano
2024-02-13 18:39           ` Rubén Justo
2024-02-13 19:39             ` Junio C Hamano
2024-02-13 19:56               ` Rubén Justo
2024-02-13 20:35                 ` Kristoffer Haugsbakk
2024-02-13 20:59                   ` Junio C Hamano
2024-02-13 23:25               ` Rubén Justo
2024-02-13 23:36                 ` [PATCH] tag: error when git-column fails Rubén Justo
2024-02-14  1:35                   ` Junio C Hamano
2024-02-13 19:27       ` [PATCH v3 0/2] column: disallow negative padding Rubén Justo
2024-02-13 20:32         ` Kristoffer Haugsbakk [this message]
2024-02-13 20:58           ` Junio C Hamano

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=dc1be818-e793-44f6-98dd-b159e043da28@app.fastmail.com \
    --to=code@khaugsbakk.name \
    --cc=chris.torek@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=rjusto@gmail.com \
    --cc=tiago@pascoal.net \
    /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).