From: Uwe Zeisberger <zeisberg@informatik.uni-freiburg.de>
To: git@vger.kernel.org
Subject: [PATCH] Fix possible out-of-bounds array access
Date: Wed, 21 Jun 2006 11:04:12 +0200 [thread overview]
Message-ID: <20060621090412.GA9267@informatik.uni-freiburg.de> (raw)
In-Reply-To: <20060620160836.GA20153@informatik.uni-freiburg.de>
If match is "", match[-1] is accessed. Let pathspec_matches return 1 in that
case indicating that "" matches everything.
Incidently this fixes git-grep'ing in ".".
Signed-off-by: Uwe Zeisberger <Uwe_Zeisberger@digi.com>
---
builtin-grep.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/builtin-grep.c b/builtin-grep.c
index 9806499..f7767bb 100644
--- a/builtin-grep.c
+++ b/builtin-grep.c
@@ -29,10 +29,11 @@ static int pathspec_matches(const char *
int matchlen = strlen(match);
const char *cp, *meta;
- if ((matchlen <= namelen) &&
- !strncmp(name, match, matchlen) &&
- (match[matchlen-1] == '/' ||
- name[matchlen] == '\0' || name[matchlen] == '/'))
+ if (!matchlen ||
+ ((matchlen <= namelen) &&
+ !strncmp(name, match, matchlen) &&
+ (match[matchlen-1] == '/' ||
+ name[matchlen] == '\0' || name[matchlen] == '/')))
return 1;
if (!fnmatch(match, name, 0))
return 1;
--
1.4.0
--
Uwe Zeisberger
http://www.google.com/search?q=12+mol+in+dozen
next prev parent reply other threads:[~2006-06-21 9:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-20 16:08 git grep in Uwe Zeisberger
2006-06-21 9:04 ` Uwe Zeisberger [this message]
2006-06-21 11:01 ` [PATCH] Fix possible out-of-bounds array access Junio C Hamano
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=20060621090412.GA9267@informatik.uni-freiburg.de \
--to=zeisberg@informatik.uni-freiburg.de \
--cc=git@vger.kernel.org \
/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).