From: Thomas Jarosch <thomas.jarosch@intra2net.com>
To: netdev@vger.kernel.org
Cc: Stephen Hemminger <shemminger@vyatta.com>
Subject: [iproute2 PATCH] Fix unterminated readlink() buffer usage
Date: Thu, 13 Oct 2011 10:30:21 +0200 [thread overview]
Message-ID: <201110131030.21723.thomas.jarosch@intra2net.com> (raw)
Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
---
misc/ss.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index b00841b..1353620 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -273,13 +273,19 @@ static void user_ent_hash_build(void)
unsigned int ino;
char lnk[64];
int fd;
+ ssize_t link_len;
if (sscanf(d1->d_name, "%d%c", &fd, &crap) != 1)
continue;
sprintf(name+pos, "%d", fd);
- if (readlink(name, lnk, sizeof(lnk)-1) < 0 ||
- strncmp(lnk, pattern, strlen(pattern)))
+
+ link_len = readlink(name, lnk, sizeof(lnk)-1);
+ if (link_len == -1)
+ continue;
+ lnk[link_len] = '\0';
+
+ if (strncmp(lnk, pattern, strlen(pattern)))
continue;
sscanf(lnk, "socket:[%u]", &ino);
--
1.7.4.4
next reply other threads:[~2011-10-13 8:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-13 8:30 Thomas Jarosch [this message]
2011-10-13 15:22 ` [iproute2 PATCH] Fix unterminated readlink() buffer usage Stephen Hemminger
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=201110131030.21723.thomas.jarosch@intra2net.com \
--to=thomas.jarosch@intra2net.com \
--cc=netdev@vger.kernel.org \
--cc=shemminger@vyatta.com \
/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).