diff mbox

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

Message ID 1336664567-4593-1-git-send-email-fw@strlen.de
State Accepted
Headers show

Commit Message

Florian Westphal May 10, 2012, 3:42 p.m. UTC
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.

Signed-off-by: Florian Westphal <fw@strlen.de>
---
 iptables/ip6tables-restore.c |    2 +-
 iptables/iptables-restore.c  |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Pablo Neira Ayuso May 14, 2012, 8:41 a.m. UTC | #1
On Thu, May 10, 2012 at 05:42:47PM +0200, Florian Westphal wrote:
> 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.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/iptables/ip6tables-restore.c b/iptables/ip6tables-restore.c
index 92bdc30..3894d68 100644
--- a/iptables/ip6tables-restore.c
+++ b/iptables/ip6tables-restore.c
@@ -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,
diff --git a/iptables/iptables-restore.c b/iptables/iptables-restore.c
index 6b1c792..034f960 100644
--- a/iptables/iptables-restore.c
+++ b/iptables/iptables-restore.c
@@ -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,