util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Buffer overrun in some calls to sscanf
@ 2012-07-09 17:15 Sergei Antonov
  2012-07-09 20:28 ` Karel Zak
  0 siblings, 1 reply; 2+ messages in thread
From: Sergei Antonov @ 2012-07-09 17:15 UTC (permalink / raw)
  To: util-linux

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)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-07-09 20:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-09 17:15 Buffer overrun in some calls to sscanf Sergei Antonov
2012-07-09 20:28 ` Karel Zak

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).