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

Re: [PATCH] fetch-pack: Avoid memcpy() with src==dst

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 8, 2008, 02:47 UTC
Message-ID
<7viqpvbcxy.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<1228596609-12720-1-git-send-email-trast@student.ethz.ch>
Thomas Rast <trast@student.ethz.ch> writes:
> memcpy() may only be used for disjoint memory areas, but when invoked
> from cmd_fetch_pack(), we have my_args == &args.  (The argument cannot
> be removed entirely because transport.c invokes with its own
> variable.)

It makes me wonder if it might be a better fix to abolish the use of file scoped global "args" and pass a pointer to "struct fetch_pack_args" throughout the callchain instead.

In the current code, cmd_fetch_pack() is the only caller that passes &args to this function, but it is not so implausible to have a future callchain that makes two calls to cmd_fetch_pack(), perhaps implementing some sort of alias to fetch from multiple places, would horribly break without such a fix, because cmd_fetch_pack() assumes that args is in its pristine state.

I'll apply this to 'maint' and merge it up, because the patch is independent of the above issue.

Thanks.
Previous: Thomas Rast
Message 2 of 2 in “fetch-pack: Avoid memcpy() with src==dst”
  1. fetch-pack: Avoid memcpy() with src==dstThomas Rast, Dec 6, 2008
  2. Junio C HamanoDec 8, 2008

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.