git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: "Ismail Dönmez" <ismail@pardus.org.tr>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [ANNOUNCE] GIT 1.5.4-rc3
Date: Sat, 12 Jan 2008 04:04:32 -0500	[thread overview]
Message-ID: <20080112090432.GA6134@coredump.intra.peff.net> (raw)
In-Reply-To: <200801120947.48602.ismail@pardus.org.tr>

On Sat, Jan 12, 2008 at 09:47:48AM +0200, Ismail Dönmez wrote:

> So looks like tests no longer work as root, so I run make test as normal user 
> and I now see t7300-clean.sh fail, this time a real failure:
> 
> Removing part3.c
> ./test-lib.sh: line 193: 19413 Aborted                 git-clean
> * FAIL 5: git-clean with prefix

I couldn't reproduce this just running the test, but running it under
valgrind showed a memory access error. Fix is below.

Junio, can you please sanity check this fix (it stops the valgrind
error, but I want to make sure my assumptions about match_pathspec are
right).

-- >8 --
git-clean: fix off-by-one memory access when given no arguments

The "seen" variable is used by match_pathspec, and must have
as many elements as there are in the given pathspec. We
create the pathspec either from the command line arguments
_or_ from just the current prefix.

Thus allocating "seen" based upon just argc is wrong, since
if argc == 0, then we still have one pathspec, the prefix,
but we don't allocate any space in "seen".

Signed-off-by: Jeff King <peff@peff.net>
---
It might be more readable to actually set a variable pathspec_size and
use that.

 builtin-clean.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin-clean.c b/builtin-clean.c
index 6cad8ea..eb853a3 100644
--- a/builtin-clean.c
+++ b/builtin-clean.c
@@ -90,7 +90,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
 	strbuf_init(&directory, 0);
 
 	if (pathspec)
-		seen = xmalloc(argc);
+		seen = xmalloc(argc > 0 ? argc : 1);
 
 	for (i = 0; i < dir.nr; i++) {
 		struct dir_entry *ent = dir.entries[i];
@@ -125,7 +125,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
 			continue;
 
 		if (pathspec) {
-			memset(seen, 0, argc);
+			memset(seen, 0, argc > 0 ? argc : 1);
 			matches = match_pathspec(pathspec, ent->name, ent->len,
 						 baselen, seen);
 		} else {
-- 
1.5.4.rc3-dirty

  parent reply	other threads:[~2008-01-12  9:05 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-12  7:11 [ANNOUNCE] GIT 1.5.4-rc3 Junio C Hamano
2008-01-12  7:26 ` Ismail Dönmez
2008-01-12  7:34   ` Junio C Hamano
2008-01-12  7:47     ` Ismail Dönmez
2008-01-12  8:04       ` Junio C Hamano
2008-01-12  9:04       ` Jeff King [this message]
2008-01-12  9:05         ` Jeff King
2008-01-12 11:10         ` valgrind test script integration Jeff King
2008-01-12 11:36           ` Jeff King
2008-01-12 17:10             ` Johannes Schindelin
2008-01-12 18:12               ` Jeff King
2008-01-12 13:01         ` [ANNOUNCE] GIT 1.5.4-rc3 René Scharfe
2008-01-12 13:10         ` Ismail Dönmez
2008-01-12 16:57         ` Johannes Schindelin
2008-01-12 18:09           ` Jeff King
2008-01-12 19:09         ` Junio C Hamano
2008-01-12 14:24 ` Roger C. Soares
2008-01-12 19:13   ` Junio C Hamano
     [not found] ` <7vsl13wmas.fsf-jO8aZxhGsIagbBziECNbOZn29agUkmeCHZ5vskTnxNA@public.gmane.org>
2008-01-13 14:41   ` Steffen Prohaska
2008-01-21  2:37 ` [ANNOUNCE] GIT 1.5.4-rc4 Junio C Hamano
     [not found]   ` <7vsl0r3nvc.fsf-jO8aZxhGsIagbBziECNbOZn29agUkmeCHZ5vskTnxNA@public.gmane.org>
2008-01-21 22:22     ` Steffen Prohaska
     [not found]       ` <BB330DC7-9F38-4D41-85A2-D475701B6083-wjoc1KHpMeg@public.gmane.org>
2008-01-22  1:21         ` Johannes Schindelin
     [not found]           ` <alpine.LSU.1.00.0801220121300.5731-OGWIkrnhIhzN0uC3ymp8PA@public.gmane.org>
2008-01-22  5:50             ` Steffen Prohaska
2008-01-28 10:56   ` [ANNOUNCE] GIT 1.5.4-rc5 Junio C Hamano
2008-01-28 18:38     ` Jeff King
2008-01-29  0:36       ` Gustaf Hendeby
2008-01-29  1:25       ` Junio C Hamano
2008-01-29  1:29         ` Jeff King
2008-01-29  6:06     ` Steffen Prohaska

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=20080112090432.GA6134@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=ismail@pardus.org.tr \
    /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).