Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 13 Mar 2012 12:24:27 -0400
From: Rich Felker <>
Subject: Re: scanf %x bug

On Tue, Mar 13, 2012 at 02:51:18PM +0100, Szabolcs Nagy wrote:
> i found a scanf bug:
> #include <stdio.h>
> int main(){
>     int n, a=7;
>     n = sscanf("0", "%x", &a);
>     printf("%d %d\n", n, a);
>     return 0;
> }
> prints 0 7
> instead of 1 0

Please tell me what you think of this patch. Note that m is the
"match" flag (m!=0 means "the sequence scanned so far is valid").

I wanted to just switch to the new __intparse code, but I feel like
it's appropriate to fix this bug first with a less invasive patch.


View attachment "scanf_fix.diff" of type "text/plain" (1052 bytes)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.