From: Junio C Hamano <gitster@pobox.com>
To: "Phillip Wood via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Taylor Blau <me@ttaylorr.com>,
Phillip Wood <phillip.wood@dunelm.org.uk>
Subject: Re: [PATCH] apply: improve error messages when reading patch
Date: Mon, 26 Jun 2023 08:58:27 -0700 [thread overview]
Message-ID: <xmqqjzvq5i70.fsf@gitster.g> (raw)
In-Reply-To: <pull.1552.git.1687772253869.gitgitgadget@gmail.com> (Phillip Wood via GitGitGadget's message of "Mon, 26 Jun 2023 09:37:33 +0000")
"Phillip Wood via GitGitGadget" <gitgitgadget@gmail.com> writes:
> From: Phillip Wood <phillip.wood@dunelm.org.uk>
>
> Commit f1c0e3946e (apply: reject patches larger than ~1 GiB, 2022-10-25)
> added a limit on the size of patch that apply will process to avoid
> integer overflows. The implementation re-used the existing error message
> for when we are unable to read the patch. This is unfortunate because (a) it
> does not signal to the user that the patch is being rejected because it
> is too large and (b) it uses error_errno() without setting errno.
Good description of the issue, and ...
> static int read_patch_file(struct strbuf *sb, int fd)
> {
> - if (strbuf_read(sb, fd, 0) < 0 || sb->len >= MAX_APPLY_SIZE)
> - return error_errno("git apply: failed to read");
> -
> + if (strbuf_read(sb, fd, 0) < 0)
> + return error_errno(_("failed to read patch"));
> + else if (sb->len >= MAX_APPLY_SIZE)
> + return error(_("patch too large"));
... quite obvious improvement. Nice.
Will queue. Thanks.
prev parent reply other threads:[~2023-06-26 15:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-26 9:37 [PATCH] apply: improve error messages when reading patch Phillip Wood via GitGitGadget
2023-06-26 15:58 ` Junio C Hamano [this message]
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=xmqqjzvq5i70.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=me@ttaylorr.com \
--cc=phillip.wood@dunelm.org.uk \
/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.