From: Phil Sutter <phil@nwl.cc>
To: netfilter-devel@vger.kernel.org
Subject: [iptables PATCH 1/2] libxtables: xtoptions: Fix for garbage access in xtables_options_xfrm()
Date: Tue, 28 Nov 2023 22:26:30 +0100 [thread overview]
Message-ID: <20231128212631.811-2-phil@nwl.cc> (raw)
In-Reply-To: <20231128212631.811-1-phil@nwl.cc>
Allocation of the temporary array did not account for a terminating NULL
entry, causing array boundary overstepping in the called
xtables_merge_options(), causing spurious errors in extension parameter
parsing.
Fixes: ed8c3ea4015f0 ("libxtables: Combine the two extension option mergers")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
libxtables/xtoptions.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libxtables/xtoptions.c b/libxtables/xtoptions.c
index e27223e339cb2..433a686c2b595 100644
--- a/libxtables/xtoptions.c
+++ b/libxtables/xtoptions.c
@@ -93,12 +93,13 @@ xtables_options_xfrm(struct option *orig_opts, struct option *oldopts,
for (num_new = 0; entry[num_new].name != NULL; ++num_new)
;
- mp = xtables_calloc(num_new, sizeof(*mp));
+ mp = xtables_calloc(num_new + 1, sizeof(*mp));
for (i = 0; i < num_new; i++) {
mp[i].name = entry[i].name;
mp[i].has_arg = entry[i].type != XTTYPE_NONE;
mp[i].val = entry[i].id;
}
+
merge = xtables_merge_options(orig_opts, oldopts, mp, offset);
free(mp);
--
2.41.0
next prev parent reply other threads:[~2023-11-28 21:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-28 21:26 [iptables PATCH 0/2] libxtables: Fix two xtoptions bugs Phil Sutter
2023-11-28 21:26 ` Phil Sutter [this message]
2023-11-28 21:26 ` [iptables PATCH 2/2] libxtables: xtoptions: Fix for non-CIDR-compatible hostmasks Phil Sutter
2023-11-29 1:21 ` [iptables PATCH 0/2] libxtables: Fix two xtoptions bugs 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=20231128212631.811-2-phil@nwl.cc \
--to=phil@nwl.cc \
--cc=netfilter-devel@vger.kernel.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).