Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Fri, 7 Jul 2017 16:41:30 -0400
From: Rich Felker <>
Subject: Re: Different scanf behaviour compared to glibc

On Fri, Jul 07, 2017 at 10:53:34PM +0300, Evgeni Stebaev wrote:
> Hi!
> sscanf returns 0 for the following code using musl, but glibc returns 1.
> %15s cannot be used here since it stops on whitespace, but it's required to
> get all remaining data after getting other fields with sscanf (not included
> in this example).
> #include <stdio.h>
> #include <string.h>
> int main(void) {
>   char data[16];
>   memset(data, '\0', sizeof(data));
>   int res = sscanf("abcde", "%15c", data);
>   printf("parse: %d %s\n", res, data);
>   return 0;
> }

This is a known glibc bug (at least #12701, maybe duplicated in
others) that they were historically unwilling to fix. musl's behavior
matches what's required by the C standard. You might be able to use %[
to achieve what you want.


Powered by blists - more mailing lists

Your e-mail address:

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