From: Eric Sunshine <sunshine@sunshineco.com>
To: "Øystein Walle" <oystwa@gmail.com>
Cc: Git List <git@vger.kernel.org>, ingy@ingy.net
Subject: Re: [PATCH v2] rev-parse: Detect missing opt-spec
Date: Fri, 2 Sep 2022 03:15:15 -0400 [thread overview]
Message-ID: <CAPig+cT0dWW9XCEsjdtUGV3as=+jftp13PVREDW=FPM-Tkgozg@mail.gmail.com> (raw)
In-Reply-To: <20220902063958.2516-1-oystwa@gmail.com>
On Fri, Sep 2, 2022 at 2:40 AM Øystein Walle <oystwa@gmail.com> wrote:
> If a line in parseopts's input starts with one of the flag characters it
> is erroneously parsed as a opt-spec where the short name of the option
> is the flag character itself and the long name is after the end of the
> string. This makes Git want to allocate SIZE_MAX bytes of memory at this
> line:
>
> o->long_name = xmemdupz(sb.buf + 2, s - sb.buf - 2);
>
> Since s and sb.buf are equal the second argument is -2 (except unsigned)
> and xmemdupz allocates len + 1 bytes, ie. -1 meaning SIZE_MAX.
>
> Avoid this by checking whether a flag character was found in the zeroth
> position.
>
> Reported-by: Ingy dot Net <ingy@ingy.net>
> Signed-off-by: Øystein Walle <oystwa@gmail.com>
> ---
>
> Thanks for the review, Eric (should I then add a Reviewed-by trailer?).
> Fixed the casing, added the suggested trailer, and remove the
> superfluous test_done which indeed was a leftover.
Thanks for addressing my minor comments.
Since I only scanned my eye over the commit message and patch text,
but didn't actually dig into the code to verify if the fix was
correct, a Reviewed-by: would be misleading, so let's not add that
trailer.
next prev parent reply other threads:[~2022-09-02 7:15 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-01 21:15 [BUG] git crashes on simple rev-parse incantation Ingy dot Net
2022-09-02 4:28 ` Øystein Walle
2022-09-02 5:06 ` [PATCH] rev-parse: Detect missing opt-spec Øystein Walle
2022-09-02 5:46 ` Eric Sunshine
2022-09-02 6:39 ` [PATCH v2] " Øystein Walle
2022-09-02 7:15 ` Eric Sunshine [this message]
2022-09-02 6:47 ` [PATCH] " SZEDER Gábor
2022-09-02 16:27 ` Junio C Hamano
2022-09-02 17:59 ` [PATCH] rev-parse --parseopt: detect " Øystein Walle
2022-09-02 18:01 ` Øystein Walle
2022-09-02 18:45 ` Junio C Hamano
2022-09-02 21:00 ` SZEDER Gábor
2022-09-02 21:29 ` Junio C Hamano
2022-09-02 17:13 ` [PATCH] rev-parse: Detect " Jeff King
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAPig+cT0dWW9XCEsjdtUGV3as=+jftp13PVREDW=FPM-Tkgozg@mail.gmail.com' \
--to=sunshine@sunshineco.com \
--cc=git@vger.kernel.org \
--cc=ingy@ingy.net \
--cc=oystwa@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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).