From: johan verrept <johan.verrept@pandora.be>
To: linux-kernel <linux-kernel@vger.kernel.org>,
Linus Torvalds <torvalds@transmeta.com>,
alan cox <alan@redhat.com>
Subject: Re: [PATCH] (Minor) Bugfixes to vsprintf.c, vsscanf().
Date: Thu, 18 Oct 2001 03:19:34 +0200 [thread overview]
Message-ID: <3BCE2E26.EB0EDEFF@pandora.be> (raw)
In-Reply-To: <3BCE1E54.D14794A5@pandora.be>
[-- Attachment #1: Type: text/plain, Size: 592 bytes --]
johan verrept wrote:
>
> hello,
>
> minor bugfix for vsprintf.c, vsscanf did not discard whitespace in input:
> - when encoutering whitespace in fmt not followed by '%'
> - in conversion where result is ignored with '*'
>
> There is another bugfix in this, don't know from who. (picked it up with uml)
> (vsscanf used to skip two characters in the fmt for a single char in the input if not in
> conversion.)
>
> Patch against 2.4.12, I am afraid.
Attached patch is beter. Both bugs are fixed and it adds fieldwidth support for conversions with
ignored results.
Again against 2.4.12.
J.
[-- Attachment #2: vsprintf.c.diff --]
[-- Type: text/plain, Size: 1226 bytes --]
--- linux-2.4.12-clean/lib/vsprintf.c Sun Sep 16 20:26:10 2001
+++ linux-2.4.12-devel/lib/vsprintf.c Thu Oct 18 03:06:47 2001
@@ -525,12 +525,15 @@
for (; *fmt; fmt++) {
/* skip any white space in format */
if (isspace(*fmt)) {
+ /* space in fmt skips all space in input */
+ while (isspace(*str)) str++;
continue;
}
/* 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;
}
@@ -540,10 +543,25 @@
* advance both strings to next white space
*/
if (*fmt == '*') {
- while (!isspace(*fmt))
+ fmt++;
+ /* get fieldwidth */
+ field_width = 0xffffffffUL;
+ if (isdigit(*fmt))
+ field_width = skip_atoi(&fmt);
+
+ /* skip possible conversion qualifier */
+ if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || *fmt == 'Z')
fmt++;
- while(!isspace(*str))
+
+ /* do not skip conversion char, the for loop will do this */
+
+ /* eat all whitespace before conversion! */
+ while(isspace(*str))
+ str++;
+ while(!isspace(*str) && field_width) {
+ field_width--;
str++;
+ }
continue;
}
prev parent reply other threads:[~2001-10-18 1:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-10-18 0:12 [PATCH] (Minor) Bugfixes to vsprintf.c, vsscanf() johan verrept
2001-10-18 1:19 ` johan verrept [this message]
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=3BCE2E26.EB0EDEFF@pandora.be \
--to=johan.verrept@pandora.be \
--cc=alan@redhat.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.