Code

Disallow the empty string as an attribute name
[git.git] / attr.c
diff --git a/attr.c b/attr.c
index f6b3f7e850f9fcf5672031049ef1d6f43e619f63..b1d1d6d791687afc98e273db983b8f8727fcd424 100644 (file)
--- a/attr.c
+++ b/attr.c
@@ -50,12 +50,10 @@ static unsigned hash_name(const char *name, int namelen)
 static int invalid_attr_name(const char *name, int namelen)
 {
        /*
-        * Attribute name cannot begin with '-' and from
-        * [-A-Za-z0-9_.].  We'd specifically exclude '=' for now,
-        * as we might later want to allow non-binary value for
-        * attributes, e.g. "*.svg      merge=special-merge-program-for-svg"
+        * 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++;