X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fiptables.c;h=8dc571095fa9387e8504666fe8dfd9b58855e999;hb=e2df20972ce0692d20479caea66b894edb5cc1b7;hp=c48199ad26c7d7059b105160e695e36b4b71d2ea;hpb=00e7aa5a3440dcfb1778109600ee0613a030ebeb;p=collectd.git diff --git a/src/iptables.c b/src/iptables.c index c48199ad..8dc57109 100644 --- a/src/iptables.c +++ b/src/iptables.c @@ -152,8 +152,12 @@ static int iptables_config (const char *key, const char *value) } else { - strncpy (temp.rule.comment, comment, - sizeof (temp.rule.comment) - 1); + temp.rule.comment = strdup (comment); + if (temp.rule.comment == NULL) + { + free (value_copy); + return (1); + } temp.rule_type = RTYPE_COMMENT; } } @@ -336,6 +340,10 @@ static int iptables_shutdown (void) for (i = 0; i < chain_num; i++) { + if ((chain_list[i] != NULL) && (chain_list[i]->rule_type == RTYPE_COMMENT)) + { + sfree (chain_list[i]->rule.comment); + } sfree (chain_list[i]); } sfree (chain_list);