git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: karsten.blees@dcon.de
Cc: git@vger.kernel.org, Johannes Sixt <j6t@kdbg.org>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	kusmabite@gmail.com, msysGit <msysgit@googlegroups.com>,
	Pat Thoyts <patthoyts@gmail.com>,
	Stefan Naewe <stefan.naewe@gmail.com>
Subject: Re: [msysGit] [PATCH] fix deletion of .git/objects sub-directories in git-prune/repack
Date: Tue, 06 Mar 2012 13:57:43 -0800	[thread overview]
Message-ID: <7vipihqtns.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <OFBC9E02C9.526DB40C-ONC12579B9.00726ECA-C12579B9.00763181@dcon.de> (karsten blees's message of "Tue, 6 Mar 2012 22:30:40 +0100")

karsten.blees@dcon.de writes:

> 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.

  parent reply	other threads:[~2012-03-06 21:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CABPQNSbo5yEosEid_SKoiCS4c8eYAaOHy4skSOBJsef+E6H6Sw@mail.gmail.com>
2012-03-06  9:18 ` [PATCH] fix deletion of .git/objects sub-directories in git-prune/repack karsten.blees
2012-03-06 18:32   ` [msysGit] " Johannes Sixt
2012-03-06 20:19     ` Junio C Hamano
2012-03-06 21:19       ` Johannes Sixt
2012-03-06 21:30       ` karsten.blees
2012-03-06 21:49         ` Junio C Hamano
2012-03-07 10:50           ` karsten.blees
2012-03-06 21:57         ` Junio C Hamano [this message]
2012-03-06 21:47     ` karsten.blees

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vipihqtns.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=j6t@kdbg.org \
    --cc=karsten.blees@dcon.de \
    --cc=kusmabite@gmail.com \
    --cc=msysgit@googlegroups.com \
    --cc=patthoyts@gmail.com \
    --cc=stefan.naewe@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).