From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: [conntrack-tools PATCH 1/4] conntrack: Fix potential array out of bounds access
Date: Tue, 20 Dec 2022 16:38:44 +0100 [thread overview]
Message-ID: <20221220153847.24152-2-phil@nwl.cc> (raw)
In-Reply-To: <20221220153847.24152-1-phil@nwl.cc>
If the link target length exceeds 'sizeof(tmp)' bytes, readlink() will
return 'sizeof(tmp)'. Using this value as index is illegal.
Fixes: b031cd2102d9b ("conntrack: pretty-print the portid")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
src/conntrack.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/conntrack.c b/src/conntrack.c
index 859a4835580b0..aa6323dfbd1b1 100644
--- a/src/conntrack.c
+++ b/src/conntrack.c
@@ -1769,7 +1769,7 @@ static char *portid2name(pid_t pid, uint32_t portid, unsigned long inode)
continue;
rl = readlink(procname, tmp, sizeof(tmp));
- if (rl <= 0 || rl > (ssize_t)sizeof(tmp))
+ if (rl <= 0 || rl >= (ssize_t)sizeof(tmp))
continue;
tmp[rl] = 0;
--
2.38.0
next prev 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 ` Phil Sutter [this message]
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 ` [conntrack-tools PATCH 4/4] conntrack: Sanitize free_tmpl_objects() Phil Sutter
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-2-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).