public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* bug in sscanf()?
@ 2014-01-09 18:57 Allan, Bruce W
  2014-01-13 23:30 ` Al Viro
  0 siblings, 1 reply; 6+ messages in thread
From: Allan, Bruce W @ 2014-01-09 18:57 UTC (permalink / raw)
  To: linux-kernel@vger.kernel.org; +Cc: Allan, Bruce W

The kernel version of sscanf() does not allow for scanning a string with multiple concatenated integers even when maximum field widths are specified to stop reading the string to delineate the individual integers.  For example, trying to read the (3) 32-bit hexadecimal integers deadbeef, 12345678 and deadc0de when provided as a concatenated string with:

	int num;
	u32 i, j, k;
	
	num = sscanf("deadbeef12345678deadc0de", "%8x%8x%8x", &i, &j, &k);

will return the number of input items successfully matched and assigned as 3, the 32-bit integers j and k will have the expected values, but i will be 0.

The libc version of sscanf(), however, will set the value of i to deadbeef.

Should this be expected with the kernel version or is it a bug?

Thanks,
Bruce.


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

end of thread, other threads:[~2014-01-14  2:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-09 18:57 bug in sscanf()? Allan, Bruce W
2014-01-13 23:30 ` Al Viro
2014-01-14  0:22   ` Linus Torvalds
2014-01-14  0:32     ` Allan, Bruce W
2014-01-14  2:47     ` Al Viro
2014-01-14  2:52       ` Al Viro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox