fix sscanf %n match at end of input string
authorJohannes Berg <johannes@sipsolutions.net>
Tue, 8 May 2007 07:27:20 +0000 (00:27 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Tue, 8 May 2007 18:15:05 +0000 (11:15 -0700)
commitc6b40d16d1cfa1a01158049bb887a9bbe48ef7ba
tree72eac6e26f928780fe722ad45ff6eeb6807d2356
parent757dea93e136b219af09d3cd56a81063fdbdef1a
fix sscanf %n match at end of input string

I was playing with some code that sometimes got a string where a %n
match should have been done where the input string ended, for example
like this:

  sscanf("abc123", "abc%d%n", &a, &n);  /* doesn't work */
  sscanf("abc123a", "abc%d%n", &a, &n); /* works */

However, the scanf function in the kernel doesn't convert the %n in that
case because it has already matched the complete input after %d and just
completely stops matching then. This patch fixes that.

[akpm@linux-foundation.org: cleanups]
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
lib/vsprintf.c