NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/48517: snprintb(3) adds extra '>' to string-converted value when nothing matches



>Number:         48517
>Category:       lib
>Synopsis:       snprintb(3) adds extra '>' to string-converted value when 
>nothing matches
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jan 13 11:50:00 +0000 2014
>Originator:     Felix Deichmann
>Release:        current and 6.1.2
>Organization:
>Environment:
- NetBSD 6.99.28 (GENERIC) amd64 build of 201401121400Z (nyftp.netbsd.org)
- NetBSD 6.1.2 (GENERIC) amd64
>Description:
When snprintb(3) has no match (e. g. converts a value of 0), it adds an extra 
'>' to the value in the converted string, e. g. "0x0>".
See the following code example.

I would expect it to just convert to "0x0" then.
>How-To-Repeat:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <util.h>

/* -------------------------------------------------------------------------- */

int
main(void)
{
        char strbuf[80];

        (void)snprintb(strbuf, sizeof(strbuf) / sizeof(strbuf[0]),
                       "\177\20"        /* new format, base 16 */
                       "b\0A\0"         /* bit 0 = A */
                       "\0",
                       0);
        printf("%s\n", strbuf); /* prints "0x0>\n"... */

        return (strcmp("0x0", strbuf) == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}

>Fix:



Home | Main Index | Thread Index | Old Index