Code

Disallow the empty string as an attribute name
[git.git] / attr.c
diff --git a/attr.c b/attr.c
index 4a1244f9a9b7ec30df5dcfee5257ea22d708fa78..b1d1d6d791687afc98e273db983b8f8727fcd424 100644 (file)
--- 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++;