git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] apply: improve error messages when reading patch

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 26, 2023, 15:58 UTC
Message-ID
<xmqqjzvq5i70.fsf@gitster.g>
In-Reply-To
<pull.1552.git.1687772253869.gitgitgadget@gmail.com>
"Phillip Wood via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 8 quoted lines
> 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 ...
Show 9 quoted lines
>  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.
Previous: Phillip Wood via GitGitGadget
Message 2 of 2 in “apply: improve error messages when reading patch”
  1. apply: improve error messages when reading patchPhillip Wood via GitGitGadget, Jun 26, 2023
  2. Junio C HamanoJun 26, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.