netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: [conntrack-tools PATCH 4/4] conntrack: Sanitize free_tmpl_objects()
Date: Tue, 20 Dec 2022 16:38:47 +0100	[thread overview]
Message-ID: <20221220153847.24152-5-phil@nwl.cc> (raw)
In-Reply-To: <20221220153847.24152-1-phil@nwl.cc>

The function unconditionally dereferenced its parameter, yet it is
possible for the passed 'cur_tmpl' pointer when called from exit_error()
to be still NULL: It is assigned to by alloc_tmpl_objects() at start of
do_parse(), though callers of that function might call exit_error() in
beforehand.

Fixes: 258b4540f4512 ("conntrack: add struct ct_tmpl")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 src/conntrack.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/conntrack.c b/src/conntrack.c
index 2bd71e17e6be6..23eaf274a78a1 100644
--- a/src/conntrack.c
+++ b/src/conntrack.c
@@ -139,6 +139,8 @@ static int alloc_tmpl_objects(struct ct_tmpl *tmpl)
 
 static void free_tmpl_objects(struct ct_tmpl *tmpl)
 {
+	if (!tmpl)
+		return;
 	if (tmpl->ct)
 		nfct_destroy(tmpl->ct);
 	if (tmpl->exptuple)
-- 
2.38.0


  parent reply	other threads:[~2022-12-20 15:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-20 15:38 [conntrack-tools PATCH 0/4] Fix some minor bugs Phil Sutter
2022-12-20 15:38 ` [conntrack-tools PATCH 1/4] conntrack: Fix potential array out of bounds access Phil Sutter
2022-12-20 15:38 ` [conntrack-tools PATCH 2/4] conntrack: Fix for unused assignment in do_command_ct() Phil Sutter
2022-12-20 15:38 ` [conntrack-tools PATCH 3/4] conntrack: Fix for unused assignment in ct_save_snprintf() Phil Sutter
2022-12-20 15:38 ` Phil Sutter [this message]
2022-12-21 16:48 ` [conntrack-tools PATCH 0/4] Fix some minor bugs Pablo Neira Ayuso
2022-12-21 16:51   ` Phil Sutter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221220153847.24152-5-phil@nwl.cc \
    --to=phil@nwl.cc \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).