From: Sergei Antonov <saproj@gmail.com>
To: util-linux@vger.kernel.org
Subject: Buffer overrun in some calls to sscanf
Date: Mon, 9 Jul 2012 19:15:57 +0200 [thread overview]
Message-ID: <CABikg9y0q1onOb2vzuxtOJt4QQL+gXR7FzNjHJffxQCJWsL5RQ@mail.gmail.com> (raw)
Hello!
Take a look at these 7 places where sscanf may write 1 zero byte past
the end of the array.
To fix this either decrease the %N limit or increase array size.
util-linux/libblkid/src/devno.c:
char name[64];
if (sscanf(buf, "%d %64[^\n ]", &maj, name) != 2)
util-linux/libblkid/src/devname.c:
char ptname0[128], ptname1[128], *ptname = 0;
char *ptnames[2];
...
int which = 0, last = 0;
...
ptnames[0] = ptname0;
ptnames[1] = ptname1;
...
which ^= 1;
ptname = ptnames[which];
if (sscanf(line, " %d %d %llu %128[^\n ]",
&ma, &mi, &sz, ptname) != 4)
util-linux/lib/sysfs.c:
char buf[1024];
return sysfs_scanf(cxt, attr, "%1024[^\n]", buf) == 1 ?
strdup(buf) : NULL;
util-linux/lib/loopdev.c:
char name[128];
if (sscanf(buf, " %u %*s %*s %128[^\n ]",
&m, name) != 2 || m != LOOPDEV_MAJOR)
util-linux/fdisks/sfdisk.c:
char line[1024], ptname[128];
...
if (sscanf(line, " %d %d %llu %128[^\n ]", &ma, &mi, &sz, ptname) != 4)
util-linux/fdisks/fdisk.c:
char line[128], ptname[128], devname[256];
...
if (sscanf (line, " %d %d %llu %128[^\n ]",
&ma, &mi, &sz, ptname) != 4)
util-linux/disk-utils/blockdev.c:
char ptname[200];
...
if (sscanf(line, " %d %d %d %200[^\n ]",
&ma, &mi, &sz, ptname) != 4)
next reply other threads:[~2012-07-09 17:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-09 17:15 Sergei Antonov [this message]
2012-07-09 20:28 ` Buffer overrun in some calls to sscanf 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=CABikg9y0q1onOb2vzuxtOJt4QQL+gXR7FzNjHJffxQCJWsL5RQ@mail.gmail.com \
--to=saproj@gmail.com \
--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;
as well as URLs for NNTP newsgroup(s).