Skip to contentSkip to conversation

ip(6)tables-restore: make sure argv is NULL terminated

PATCH Applied Florian Westphal 2 participants 2 messages May 10, 2012 – May 14, 2012 netfilter

lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 ip(6)tables-restore: make sure argv is NULL terminated

Else, argv[argc] may point to free'd memory.

Some extensions, e.g. rateest, may fail to parse valid input because argv[optind] (with optind == argc) is not NULL.

---
 iptables/ip6tables-restore.c |    2 +-
 iptables/iptables-restore.c  |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
iptables/ip6tables-restore.c +1 -1
index 92bdc30..3894d68 100644
@@ -98,7 +98,7 @@ static int add_argv(char *what) {
 	DEBUGP("add_argv: %s\n", what);
 	if (what && newargc + 1 < ARRAY_SIZE(newargv)) {
 		newargv[newargc] = strdup(what);
-		newargc++;
+		newargv[++newargc] = NULL;
 		return 1;
 	} else {
 		xtables_error(PARAMETER_PROBLEM,
iptables/iptables-restore.c +1 -1
index 6b1c792..034f960 100644
@@ -97,7 +97,7 @@ static int add_argv(char *what) {
 	DEBUGP("add_argv: %s\n", what);
 	if (what && newargc + 1 < ARRAY_SIZE(newargv)) {
 		newargv[newargc] = strdup(what);
-		newargc++;
+		newargv[++newargc] = NULL;
 		return 1;
 	} else {
 		xtables_error(PARAMETER_PROBLEM,
Signature · 1 line
1.7.3.4
maintainer Applied
#1 lore raw
Quoted 4 lines · Florian Westphal

Else, argv[argc] may point to free'd memory.

Some extensions, e.g. rateest, may fail to parse valid input because argv[optind] (with optind == argc) is not NULL.

Applied, thanks Florian.