bin/181152: %i fails with negative hex numbers with sscanf

Garrett Cooper yaneurabeya at gmail.com
Fri Aug 9 00:20:00 UTC 2013


>Number:         181152
>Category:       bin
>Synopsis:       %i fails with negative hex numbers with sscanf
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Aug 09 00:20:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     Garrett Cooper
>Release:        10-CURRENT
>Organization:
EMC Isilon
>Environment:
FreeBSD fuji-current.local 10.0-CURRENT FreeBSD 10.0-CURRENT #10 c9d2bd6-dirty: Wed Aug  7 18:55:03 PDT 2013     root at fuji-current.local:/usr/obj/usr/src/sys/FUJI-NOCOMPAT  i386
>Description:
Looks like FreeBSD has lib/21691:

    sscanf_neghex: [0.001912s] Failed: /usr/src/lib/libc/tests/stdio/t_scanf.c:50: i == NUM not met

The snippet of test code that exhibits this is:

#define NUM     -0x1234
#define STRNUM  __STRING(NUM)

ATF_TC(sscanf_neghex);
ATF_TC_HEAD(sscanf_neghex, tc)
{
        atf_tc_set_md_var(tc, "descr",
            "PR lib/21691: %%i and %%x fail with negative hex numbers");
}

ATF_TC_BODY(sscanf_neghex, tc)
{
        int i;

        sscanf(STRNUM, "%i", &i);
        ATF_REQUIRE(i == NUM);

        sscanf(STRNUM, "%x", &i);
        ATF_REQUIRE(i == NUM);
}
>How-To-Repeat:

>Fix:


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list