fix gcc build, introduce a hard limit on ini section size

This commit is contained in:
Enno Rehling 2017-01-21 20:39:46 +01:00 committed by Enno Rehling
parent c6584d83d2
commit dbc6a17e66
1 changed files with 2 additions and 8 deletions

View File

@ -720,15 +720,12 @@ void config_set_from(const dictionary *d)
char key[128];
const char *sec = iniparser_getsecname(d, s);
int k, nkeys = iniparser_getsecnkeys(d, sec);
char *akeys[MAXKEYS];
char ** keys = akeys;
const char *keys[MAXKEYS];
size_t slen = strlen(sec);
assert(nkeys <= MAXKEYS);
assert(slen<sizeof(key));
memcpy(key, sec, slen);
key[slen] = '.';
if (nkeys>MAXKEYS) {
keys = malloc(sizeof(const char *) * nkeys);
}
iniparser_getseckeys(d, sec, keys);
for (k=0;k!=nkeys;++k) {
const char *val;
@ -740,9 +737,6 @@ void config_set_from(const dictionary *d)
config_set(key, val);
}
}
if (keys!=akeys) {
free(keys);
}
}
}