mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Fix sscanf
@ 2001-09-24  3:54 Jeff Dike
  2001-09-24  7:13 ` [PATCH] Fix sscanf (the 3rd verse) Paul
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff Dike @ 2001-09-24  3:54 UTC (permalink / raw)
  To: torvalds, alan; +Cc: linux-kernel

sscanf double-increments fmt in a couple of places, causing format characters
to be skipped.  Patch follows.

I'm a bit unhappy about the second chunk, but I don't see a cleaner way to
do it offhand.

				Jeff

--- orig/lib/vsprintf.c	Sun Sep 23 19:20:54 2001
+++ 2.4.10/lib/vsprintf.c	Sun Sep 23 21:28:55 2001
@@ -530,7 +530,8 @@
 
 		/* anything that is not a conversion must match exactly */
 		if (*fmt != '%') {
-			if (*fmt++ != *str++)
+		        /* Don't bump fmt because the for header will do it */
+			if (*fmt != *str++)
 				return num;
 			continue;
 		}
@@ -542,6 +543,10 @@
 		if (*fmt == '*') {
 			while (!isspace(*fmt))
 				fmt++;
+			/* Back it up one because the for header will move it
+			 * it forward again
+			 */
+			fmt--;
 			while(!isspace(*str))
 				str++;
 			continue;


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

end of thread, other threads:[~2001-09-24 18:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-24  3:54 [PATCH] Fix sscanf Jeff Dike
2001-09-24  7:13 ` [PATCH] Fix sscanf (the 3rd verse) Paul
2001-09-24 18:05   ` [PATCH] Fix sscanf (more fixes) Paul

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

all inboxes | Powered by JetHome®