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

Re: [PATCH] fetch-pack: check for valid commit from server

From
Shawn Pearce <spearce@spearce.org>
Date
Aug 18, 2011, 21:32 UTC
Message-ID
<CAJo=hJvN9W00ncG53933yiqT++QCxGLUqp8KtG=BsvKD81wWyA@mail.gmail.com>
In-Reply-To
<1313674563-12755-1-git-send-email-pclouds@gmail.com>
2011/8/18 Nguyễn Thái Ngọc Duy <pclouds@gmail.com>:
Show 9 quoted lines
> A malicious server can return ACK with non-existent SHA-1 or not a
> commit. lookup_commit() in this case may return NULL. Do not let
> fetch-pack crash by accessing NULL address in this case.
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  However it raises another question, what if the other end returns a
>  valid commit, but not the one in "have" line fetch-pack sent? Are we
>  OK with that?

Not really. The server is not supposed to return a SHA-1 in the ACK line unless the client said it first in a have line. So aborting with an error is reasonable thing for a client to do.

> +                                       if (!commit)
> +                                               die("invalid commit %s", sha1_to_hex(result_sha1));
Maybe:
  die("server ACK contained unknown commit %s", sha1_to_hex(result_sha1));
is more specific to the problem.
Just curious, did you see this on a particular server somewhere?
-- 
Shawn.
Previous: Nguyễn Thái Ngọc DuyNext: Nguyen Thai Ngoc Duy
Message 2 of 5 in “fetch-pack: check for valid commit from server”
  1. fetch-pack: check for valid commit from serverNguyễn Thái Ngọc Duy, Aug 18, 2011
  2. Shawn PearceAug 18, 2011
  3. Nguyen Thai Ngoc DuyAug 19, 2011
  4. fetch-pack: check for valid commit from serverNguyễn Thái Ngọc Duy, Aug 19, 2011
  5. Junio C HamanoAug 19, 2011

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.