Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Jun 2017 14:13:55 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-bugs@FreeBSD.org
Subject:   [Bug 219926] sscanf(3): Inconsistent return value on match failures with patterns like "%*s%u" when compared to other implementations
Message-ID:  <bug-219926-8@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D219926

            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@FreeBSD.org
          Reporter: tobik@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 =3D sscanf("foo", "%*s%u", &i);
        printf("n =3D %d\n", n);
        return 0;
}

n =3D 0 on FreeBSD 11.0 and 12.0-CURRENT
n =3D 0 on DragonFly BSD 4.6.0rc2
n =3D 0 on NetBSD 7.0.1
n =3D -1 on Ubuntu 16.04 (Glibc 2.23)
n =3D -1 on Alpine Linux (musl 1.1.16)
n =3D -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?

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-219926-8>