Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 15 Nov 2013 15:47:02 -0500
From: Rich Felker <>
Subject: Re: sscanf(3) return value doesn't count %100c assignments

On Fri, Nov 15, 2013 at 08:23:42PM +0000, David Wuertele wrote:
> Comparing musl-0.9.14 with glibc-2.13, I find sscanf(3) behaves
> differently.  In Glibc, sscanf() returns the same assignment counts when
> using %Nc compared with using %s, but in Mulsl, sscanf returns different
> assignment counts.
> For example, take the following two instructions:
>   sscanf (string, "%d %s", &number, remainder);
>   sscanf (string, "%d %100c", &number, remainder);
> If each of these makes two assignments, they should both return 2.
> Glibc works this way.  But even though with Musl they both make two
> assignments, Musl sscanf() returns 2 for the %s and it returns 1 for
> the %100c version.

musl's sscanf returns 1 because only the %d was matched. %100c
requires _exactly_ 100 characters; anything shorter is a matching
failure. See C99 The fscanf function, paragraph 12:

    12 The conversion specifiers and their meanings are:



    Matches a sequence of characters of exactly the number specified
    by the field width (1 if no field width is present in the

What you're seeing is a known bug in glibc:

It's an old WONTFIX from the days when Ulrich Drepper was maintainer.


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.