mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jeff Dike <jdike@karaya.com>
To: torvalds@transmeta.com, alan@lxorguk.ukuu.org.uk
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] Fix sscanf
Date: Sun, 23 Sep 2001 22:54:10 -0500	[thread overview]
Message-ID: <200109240354.WAA03909@ccure.karaya.com> (raw)

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;


             reply	other threads:[~2001-09-24  2:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-24  3:54 Jeff Dike [this message]
2001-09-24  7:13 ` [PATCH] Fix sscanf (the 3rd verse) Paul
2001-09-24 18:05   ` [PATCH] Fix sscanf (more fixes) Paul

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=200109240354.WAA03909@ccure.karaya.com \
    --to=jdike@karaya.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /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

all inboxes | Powered by JetHome®