[Bug 219926] sscanf(3): Inconsistent return value on match failures with patterns like "%*s%u" when compared to other implementations

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Sun Jun 11 14:13:55 UTC 2017


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=219926

            Bug ID: 219926
           Summary: sscanf(3): Inconsistent return value on match failures
                    with patterns like "%*s%u" when compared to other
                    implementations
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: freebsd-bugs at FreeBSD.org
          Reporter: tobik at freebsd.org

When using a pattern that starts with "%*s" followed by one or more
other conversions, the sscanf(3) implementation in FreeBSD's libc
behaves differently than the sscanf() implementations in other libcs.
For example running this small test program on a bunch of different
systems gives the following results:

#include <stdio.h>

int
main(int argc, char *argv[])
{
        unsigned int i;
        int n = sscanf("foo", "%*s%u", &i);
        printf("n = %d\n", n);
        return 0;
}

n = 0 on FreeBSD 11.0 and 12.0-CURRENT
n = 0 on DragonFly BSD 4.6.0rc2
n = 0 on NetBSD 7.0.1
n = -1 on Ubuntu 16.04 (Glibc 2.23)
n = -1 on Alpine Linux (musl 1.1.16)
n = -1 on OpenBSD 6.1

Glibc, musl, and OpenBSD's libc all return EOF in this case.

netpbm's ppmtoarbtxt uses a similar pattern and would fail to work
correctly on FreeBSD because it expects that EOF is returned after a
match failure.  This has been worked around now upstream by not using
"%*s" first in the pattern.  But I'm wondering if this a bug or if
this is ok?

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list