This fixes the (mostly theoretical, since we're only parsing data that we write
ourselves) memleak when iif or oif is deserialized multiple times. Unfortunately
it does not fix the memleak when rule is freed, but that'll require a bigger
effort.
}
} else if (streq(a, "iif")) {
- rule->iif = strdup(b);
- if (!rule->iif)
+ if (free_and_strdup(&rule->iif, b) < 0)
return log_oom();
+
} else if (streq(a, "oif")) {
- rule->oif = strdup(b);
- if (!rule->oif)
+ if (free_and_strdup(&rule->oif, b) < 0)
return log_oom();
}
}
test_rule_serialization("outgoing interface",
"RULE=from=1::2/64 to=2::3/64 oif=eth0 table=1", NULL);
+ test_rule_serialization("freeing interface names",
+ "RULE=from=1::2/64 to=2::3/64 iif=e0 iif=e1 oif=e0 oif=e1 table=1",
+ "RULE=from=1::2/64 to=2::3/64 iif=e1 oif=e1 table=1");
+
return 0;
}