From patchwork Thu May 10 15:42:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Westphal X-Patchwork-Id: 158335 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 478CAB6F9D for ; Fri, 11 May 2012 01:41:00 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753249Ab2EJPk6 (ORCPT ); Thu, 10 May 2012 11:40:58 -0400 Received: from Chamillionaire.breakpoint.cc ([80.244.247.6]:58172 "EHLO Chamillionaire.breakpoint.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753102Ab2EJPk6 (ORCPT ); Thu, 10 May 2012 11:40:58 -0400 Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.72) (envelope-from ) id 1SSVU8-0002gu-Oo; Thu, 10 May 2012 17:40:56 +0200 From: Florian Westphal To: netfilter-devel Cc: Florian Westphal Subject: [PATCH 1/1] ip(6)tables-restore: make sure argv is NULL terminated Date: Thu, 10 May 2012 17:42:47 +0200 Message-Id: <1336664567-4593-1-git-send-email-fw@strlen.de> X-Mailer: git-send-email 1.7.3.4 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org 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 --- iptables/ip6tables-restore.c | 2 +- iptables/iptables-restore.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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,