Fix a segfault if rc.conf does not exist, Gentoo #214887
This commit is contained in:
parent
f90f2914b9
commit
cee3ccc4c1
@ -203,6 +203,9 @@ char *rc_config_value(RC_STRINGLIST *list, const char *entry)
|
|||||||
RC_STRING *line;
|
RC_STRING *line;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
|
if (!list)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
TAILQ_FOREACH(line, list, entries) {
|
TAILQ_FOREACH(line, list, entries) {
|
||||||
p = strchr(line->value, '=');
|
p = strchr(line->value, '=');
|
||||||
if (p &&
|
if (p &&
|
||||||
|
@ -79,20 +79,24 @@ char *rc_conf_value(const char *setting)
|
|||||||
if (exists(RC_CONF_OLD)) {
|
if (exists(RC_CONF_OLD)) {
|
||||||
old = rc_config_load(RC_CONF_OLD);
|
old = rc_config_load(RC_CONF_OLD);
|
||||||
if (old) {
|
if (old) {
|
||||||
TAILQ_CONCAT(rc_conf, old, entries);
|
if (rc_conf) {
|
||||||
free(old);
|
TAILQ_CONCAT(rc_conf, old, entries);
|
||||||
|
free(old);
|
||||||
|
} else
|
||||||
|
rc_conf = old;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert old uppercase to lowercase */
|
/* Convert old uppercase to lowercase */
|
||||||
TAILQ_FOREACH(s, rc_conf, entries) {
|
if (rc_conf)
|
||||||
p = s->value;
|
TAILQ_FOREACH(s, rc_conf, entries) {
|
||||||
while (p && *p && *p != '=') {
|
p = s->value;
|
||||||
if (isupper((int) *p))
|
while (p && *p && *p != '=') {
|
||||||
*p = tolower((int) *p);
|
if (isupper((int) *p))
|
||||||
p++;
|
*p = tolower((int) *p);
|
||||||
|
p++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc_config_value(rc_conf, setting);
|
return rc_config_value(rc_conf, setting);
|
||||||
|
Loading…
Reference in New Issue
Block a user