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

Re: [msysGit] [PATCH] fix deletion of .git/objects sub-directories in git-prune/repack

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 6, 2012, 21:57 UTC
Message-ID
<7vipihqtns.fsf@alter.siamese.dyndns.org>
In-Reply-To
<OFBC9E02C9.526DB40C-ONC12579B9.00726ECA-C12579B9.00763181@dcon.de>
karsten.blees@dcon.de writes:
Show 10 quoted lines
> OT: While looking at the code I just stumbled across this immediately
> above the patch (prune-packed.c line 32ff):
>
>                 memcpy(pathname + len, de->d_name, 38);
>                 if (opts & DRY_RUN)
>                         printf("rm -f %s\n", pathname);
>                 else
>                         unlink_or_warn(pathname);
>
> Shouldn't this be memcpy(..., 39) (i.e. including '\0')?

I think the only thing that is guaranteeing that pathname[len+38] is NUL is that we do not hop around repositories, so once we fill the static char pathname[PATH_MAX] in prune_packed_objects(), nobody writes to that location, because the length of the leading part (i.e. "len" given to prune_dir()) will stay constant during the lifetime of the process.

So it is not currently a problem, but it would be better to clear that byte here.

Good eyes.
Previous: karsten.blees@dcon.deNext: karsten.blees@dcon.de
Message 8 of 9 in “fix deletion of .git/objects sub-directories in git-prune/repack”
  1. fix deletion of .git/objects sub-directories in git-prune/repackkarsten.blees@dcon.de, Mar 6, 2012
  2. Johannes SixtMar 6, 2012
  3. Junio C HamanoMar 6, 2012
  4. Johannes SixtMar 6, 2012
  5. karsten.blees@dcon.deMar 6, 2012
  6. Junio C HamanoMar 6, 2012
  7. karsten.blees@dcon.deMar 7, 2012
  8. Junio C HamanoMar 6, 2012
  9. karsten.blees@dcon.deMar 6, 2012

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.