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

Re: [PATCH 2/2] gpg-interface: avoid buffer overrun in parse_ssh_output()

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 1, 2021, 06:07 UTC
Message-ID
<xmqq4k8we7ec.fsf@gitster.g>
In-Reply-To
<a72ebd19-9871-f811-cd5c-72b89dad6c6f@web.de>
René Scharfe <l.s.r@web.de> writes:
Show 8 quoted lines
> If the string "key" we found in the output of ssh-keygen happens to be
> located at the very end of the line, then going four characters further
> leaves us beyond the end of the string.  Explicitly search for the
> space after "key" to handle a missing one gracefully.
>
> Signed-off-by: René Scharfe <l.s.r@web.de>
> ---
> This code was added after v2.33.0.
Thanks.

Fabian, we are in -rc phase where we concentrate on fixing bugs in the new code in 'master'. A quick ack, "here is a better way to fix it", or "no, that won't be needed because..." is very much appreciated.

Show 21 quoted lines
>  gpg-interface.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/gpg-interface.c b/gpg-interface.c
> index 62d340e78a..3838536f0a 100644
> --- a/gpg-interface.c
> +++ b/gpg-interface.c
> @@ -409,9 +409,9 @@ static void parse_ssh_output(struct signature_check *sigc)
>  		goto cleanup;
>  	}
>
> -	key = strstr(line, "key");
> +	key = strstr(line, "key ");
>  	if (key) {
> -		sigc->fingerprint = xstrdup(strstr(line, "key") + 4);
> +		sigc->fingerprint = xstrdup(strstr(line, "key ") + 4);
>  		sigc->key = xstrdup(sigc->fingerprint);
>  	} else {
>  		/*
> --
> 2.33.1
Previous: René ScharfeNext: Fabian Stelzer
Message 3 of 8 in “gpg-interface: handle missing " with " gracefully in parse_ssh_output()”
  1. 1/2 gpg-interface: handle missing " with " gracefully in parse_ssh_output()René Scharfe, Oct 30, 2021
  2. 2/2 gpg-interface: avoid buffer overrun in parse_ssh_output()René Scharfe, Oct 30, 2021
  3. Junio C HamanoNov 1, 2021
  4. Fabian StelzerNov 1, 2021
  5. Junio C HamanoNov 1, 2021
  6. Junio C HamanoNov 1, 2021
  7. Fabian StelzerNov 1, 2021
  8. René ScharfeNov 1, 2021

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.