mirror of
https://github.com/systemd/systemd.git
synced 2024-11-01 17:51:22 +03:00
Merge pull request #10607 from yuwata/fix-10605
network: fix segfault in manager_free()
This commit is contained in:
commit
9cbdf5db48
@ -785,7 +785,7 @@ static int link_set_routing_policy_rule(Link *link) {
|
||||
LIST_FOREACH(rules, rule, link->network->rules) {
|
||||
r = routing_policy_rule_get(link->manager, rule->family, &rule->from, rule->from_prefixlen, &rule->to,
|
||||
rule->to_prefixlen, rule->tos, rule->fwmark, rule->table, rule->iif, rule->oif, &rrule);
|
||||
if (r == 1) {
|
||||
if (r == 0) {
|
||||
(void) routing_policy_rule_make_local(link->manager, rrule);
|
||||
continue;
|
||||
}
|
||||
|
@ -1451,8 +1451,10 @@ void manager_free(Manager *m) {
|
||||
while ((pool = m->address_pools))
|
||||
address_pool_free(pool);
|
||||
|
||||
set_free_with_destructor(m->rules, routing_policy_rule_free);
|
||||
set_free_with_destructor(m->rules_foreign, routing_policy_rule_free);
|
||||
/* routing_policy_rule_free() access m->rules and m->rules_foreign.
|
||||
* So, it is necessary to set NULL after the sets are freed. */
|
||||
m->rules = set_free_with_destructor(m->rules, routing_policy_rule_free);
|
||||
m->rules_foreign = set_free_with_destructor(m->rules_foreign, routing_policy_rule_free);
|
||||
set_free_with_destructor(m->rules_saved, routing_policy_rule_free);
|
||||
|
||||
sd_event_unref(m->event);
|
||||
|
@ -92,9 +92,11 @@ void prefix_free(Prefix *prefix) {
|
||||
assert(prefix->network->n_static_prefixes > 0);
|
||||
prefix->network->n_static_prefixes--;
|
||||
|
||||
if (prefix->section)
|
||||
if (prefix->section) {
|
||||
hashmap_remove(prefix->network->prefixes_by_section,
|
||||
prefix->section);
|
||||
network_config_section_free(prefix->section);
|
||||
}
|
||||
}
|
||||
|
||||
prefix->radv_prefix = sd_radv_prefix_unref(prefix->radv_prefix);
|
||||
|
@ -79,10 +79,10 @@ static void routing_policy_rule_hash_func(const void *b, struct siphash *state)
|
||||
siphash24_compress(&rule->table, sizeof(rule->table), state);
|
||||
|
||||
if (rule->iif)
|
||||
siphash24_compress(&rule->iif, strlen(rule->iif), state);
|
||||
siphash24_compress(rule->iif, strlen(rule->iif), state);
|
||||
|
||||
if (rule->oif)
|
||||
siphash24_compress(&rule->oif, strlen(rule->oif), state);
|
||||
siphash24_compress(rule->oif, strlen(rule->oif), state);
|
||||
|
||||
break;
|
||||
default:
|
||||
@ -188,7 +188,7 @@ int routing_policy_rule_get(Manager *m,
|
||||
if (existing) {
|
||||
if (ret)
|
||||
*ret = existing;
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -ENOENT;
|
||||
@ -257,8 +257,8 @@ static int routing_policy_rule_add_internal(Manager *m,
|
||||
rule->tos = tos;
|
||||
rule->fwmark = fwmark;
|
||||
rule->table = table;
|
||||
rule->iif = TAKE_PTR(iif);
|
||||
rule->oif = TAKE_PTR(oif);
|
||||
rule->iif = iif;
|
||||
rule->oif = oif;
|
||||
|
||||
r = set_ensure_allocated(rules, &routing_policy_rule_hash_ops);
|
||||
if (r < 0)
|
||||
@ -272,6 +272,7 @@ static int routing_policy_rule_add_internal(Manager *m,
|
||||
*ret = rule;
|
||||
|
||||
rule = NULL;
|
||||
iif = oif = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user