From: Tobias Stoeckmann <tobias@stoeckmann.org>
To: util-linux@vger.kernel.org
Subject: lscpu: theoretical buffer overflow
Date: Sun, 26 Oct 2014 18:41:24 +0100 [thread overview]
Message-ID: <20141026174124.GA22563@fungi.pizza.local> (raw)
Hi,
there is a theoretical buffer overflow possible in the hypervisor
parsing code of lscpu. It would require a proc entry to return way more
than expected so it's no high priority. But better be safe than sorry.
At first I thought about switching to fgets but there is another
code file that adds a format specifier. The diff is less intrusive
that way, too.
Tobias
---
sys-utils/lscpu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index ef59410..c272dc2 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -621,7 +621,7 @@ read_hypervisor_powerpc(struct lscpu_desc *desc)
fd = path_fopen("r", 0, _PATH_PROC_DEVICETREE "/ibm,partition-name");
if (fd) {
char buf[256];
- if (fscanf(fd, "%s", buf) == 1 && !strcmp(buf, "full"))
+ if (fscanf(fd, "%255s", buf) == 1 && !strcmp(buf, "full"))
desc->virtype = VIRT_NONE;
fclose(fd);
}
@@ -757,7 +757,7 @@ read_hypervisor(struct lscpu_desc *desc, struct lscpu_modifier *mod)
if (fd) {
char buf[256];
- if (fscanf(fd, "%s", buf) == 1 &&
+ if (fscanf(fd, "%255s", buf) == 1 &&
!strcmp(buf, "control_d"))
dom0 = 1;
fclose(fd);
--
2.1.1
next reply other threads:[~2014-10-26 17:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-26 17:41 Tobias Stoeckmann [this message]
2014-11-18 10:40 ` lscpu: theoretical buffer overflow Karel Zak
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=20141026174124.GA22563@fungi.pizza.local \
--to=tobias@stoeckmann.org \
--cc=util-linux@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