aboutsummaryrefslogtreecommitdiff
path: root/attr.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2011-08-04 06:36:14 +0200
committerJunio C Hamano <gitster@pobox.com>2011-08-04 15:53:15 -0700
commitc0b13b21b8daa4bfb222e9c4d335c8b340c511a0 (patch)
tree92db170d41d4b9ba30daf5ef623196dacf7bd189 /attr.c
parentd42453ab1a482df0fdb428c20de1189a21a2bee1 (diff)
downloadgit-c0b13b21b8daa4bfb222e9c4d335c8b340c511a0.tar.gz
git-c0b13b21b8daa4bfb222e9c4d335c8b340c511a0.tar.xz
Disallow the empty string as an attribute name
Previously, it was possible to have a line like "file.txt =foo" in a .gitattribute file, after which an invocation like "git check-attr '' -- file.txt" would succeed. This patch disallows both constructs. Please note that any existing .gitattributes file that tries to set an empty attribute will now trigger the error message "error: : not a valid attribute name" whereas previously the nonsense was allowed through. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'attr.c')
-rw-r--r--attr.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/attr.c b/attr.c
index 4a1244f9a..b1d1d6d79 100644
--- a/attr.c
+++ b/attr.c
@@ -53,7 +53,7 @@ static int invalid_attr_name(const char *name, int namelen)
* Attribute name cannot begin with '-' and must consist of
* characters from [-A-Za-z0-9_.].
*/
- if (*name == '-')
+ if (namelen <= 0 || *name == '-')
return -1;
while (namelen--) {
char ch = *name++;