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

Re: [PATCH] Fix strcat() on uninitialized memory

From
Jay Soffian <jaysoffian@gmail.com>
Date
Jun 14, 2010, 16:34 UTC
Message-ID
<AANLkTimSFwn1yykyEOTRdHHBYTFUEhxqj2AinjRv9ECC@mail.gmail.com>
In-Reply-To
<alpine.DEB.1.00.1006141032250.2689@bonsai2>
Thanks, this was caught last week and patch posted by Thomas:
http://marc.info/?l=git&m=127619546001346&w=2
j.

On Mon, Jun 14, 2010 at 12:19 PM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:

Show 31 quoted lines
>
> Under certain circumstances, this bug would trigger a buffer overflow
> error with libc, and fail test 5516.
>
> Strbufs would have avoided the issue.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>  builtin/receive-pack.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
> index 05071c3..1644424 100644
> --- a/builtin/receive-pack.c
> +++ b/builtin/receive-pack.c
> @@ -569,9 +569,9 @@ static void check_aliased_update(struct command *cmd, struct string_list *list)
>        dst_cmd->skip_update = 1;
>
>        strcpy(cmd_oldh, find_unique_abbrev(cmd->old_sha1, DEFAULT_ABBREV));
> -       strcat(cmd_newh, find_unique_abbrev(cmd->new_sha1, DEFAULT_ABBREV));
> +       strcpy(cmd_newh, find_unique_abbrev(cmd->new_sha1, DEFAULT_ABBREV));
>        strcpy(dst_oldh, find_unique_abbrev(dst_cmd->old_sha1, DEFAULT_ABBREV));
> -       strcat(dst_newh, find_unique_abbrev(dst_cmd->new_sha1, DEFAULT_ABBREV));
> +       strcpy(dst_newh, find_unique_abbrev(dst_cmd->new_sha1, DEFAULT_ABBREV));
>        rp_error("refusing inconsistent update between symref '%s' (%s..%s) and"
>                 " its target '%s' (%s..%s)",
>                 cmd->ref_name, cmd_oldh, cmd_newh,
> --
> 1.7.1.msysgit.0.2.g2fefc8
>
>
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 2 of 4 in “Fix strcat() on uninitialized memory”
  1. Fix strcat() on uninitialized memoryJohannes Schindelin, Jun 14, 2010
  2. Jay SoffianJun 14, 2010
  3. Johannes SchindelinJun 14, 2010
  4. Jay SoffianJun 14, 2010

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.