Merge branch 'bw/config-lift-variable-name-length-limit' into maint
The configuration parser had an unnecessary hardcoded limit on
variable names that was not checked consistently.
* bw/config-lift-variable-name-length-limit:
Remove the hard coded length limit on variable names in config files
@ -260,7 +258,7 @@ static inline int iskeychar(int c)
@@ -260,7 +258,7 @@ static inline int iskeychar(int c)
return isalnum(c) || c == '-';
}
static int get_value(config_fn_t fn, void *data, char *name, unsigned int len)
static int get_value(config_fn_t fn, void *data, struct strbuf *name)
{
int c;
char *value;
@ -272,11 +270,9 @@ static int get_value(config_fn_t fn, void *data, char *name, unsigned int len)
@@ -272,11 +270,9 @@ static int get_value(config_fn_t fn, void *data, char *name, unsigned int len)
break;
if (!iskeychar(c))
break;
name[len++] = tolower(c);
if (len >= MAXNAME)
return -1;
strbuf_addch(name, tolower(c));
}
name[len] = 0;
while (c == ' ' || c == '\t')
c = get_next_char();
@ -288,10 +284,10 @@ static int get_value(config_fn_t fn, void *data, char *name, unsigned int len)
@@ -288,10 +284,10 @@ static int get_value(config_fn_t fn, void *data, char *name, unsigned int len)
if (!value)
return -1;
}
return fn(name, value, data);
return fn(name->buf, value, data);
}
static int get_extended_base_var(char *name, int baselen, int c)
static int get_extended_base_var(struct strbuf *name, int c)
{
do {
if (c == '\n')
@ -302,7 +298,7 @@ static int get_extended_base_var(char *name, int baselen, int c)
@@ -302,7 +298,7 @@ static int get_extended_base_var(char *name, int baselen, int c)
/* We require the format to be '[base "extension"]' */
if (c != '"')
return -1;
name[baselen++] = '.';
strbuf_addch(name, '.');
for (;;) {
int c = get_next_char();
@ -315,37 +311,31 @@ static int get_extended_base_var(char *name, int baselen, int c)
@@ -315,37 +311,31 @@ static int get_extended_base_var(char *name, int baselen, int c)
if (c == '\n')
goto error_incomplete_line;
}
name[baselen++] = c;
if (baselen > MAXNAME / 2)
return -1;
strbuf_addch(name, c);
}
/* Final ']' */
if (get_next_char() != ']')
return -1;
return baselen;
return 0;
error_incomplete_line:
cf->linenr--;
return -1;
}
static int get_base_var(char *name)
static int get_base_var(struct strbuf *name)
{
int baselen = 0;
for (;;) {
int c = get_next_char();
if (cf->eof)
return -1;
if (c == ']')
return baselen;
return 0;
if (isspace(c))
return get_extended_base_var(name, baselen, c);
return get_extended_base_var(name, c);
if (!iskeychar(c) && c != '.')
return -1;
if (baselen > MAXNAME / 2)
return -1;
name[baselen++] = tolower(c);
strbuf_addch(name, tolower(c));
}
}
@ -353,7 +343,7 @@ static int git_parse_file(config_fn_t fn, void *data)
@@ -353,7 +343,7 @@ static int git_parse_file(config_fn_t fn, void *data)