NetBSD-Bugs archive

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

lib/49871: strunvis cannot decode strvis output



>Number:         49871
>Category:       lib
>Synopsis:       strunvis cannot decode strvis output
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun May 03 08:50:01 +0000 2015
>Originator:     Michael van Elst
>Release:        NetBSD 7.99.12
>Organization:
-- 
                                Michael van Elst
Internet: mlelstv%serpens.de@localhost
                                "A potential Snark may lurk in every tree."
>Environment:
	
	
System: NetBSD twitty 7.99.12 NetBSD 7.99.12 (HOPPA) #8: Sun Apr 26 13:29:18 CEST 2015 mlelstv@pussyfoot:/home/netbsd-current/obj.evbarm/home/netbsd-current/src/sys/arch/evbarm/compile/HOPPA evbarm
Architecture: earmv6hf
Machine: evbarm
>Description:
strvis produces a somewhat readable encoding of arbitrary strings
or (with strvisx) byte sequences. strunvis is supposed to decode
the output into the the original string or byte sequence.

However, strvis can produce the sequence '\\','-',c for a byte
value c between 0 and 127 under rare conditions. This sequence
is not even a valid encoding as understood by strunvis.

strvis/strunvis is used by utmp_update to pass a binary structure
to the utmp_update program. This fails when the binary structure
contains a byte sequence that is misinterpreted that way.

>How-To-Repeat:

#include <stdio.h>
#include <vis.h>
#include <locale.h>

int main()
{
        char input[] = "\335\272";
        char output[(sizeof(input)-1)*4+1];

        setlocale(LC_ALL, "de_DE.UTF-8");
        strvisx(output, input, sizeof(input)-1, VIS_WHITE);

        printf("%s\n", output);

        return 0;
}

prints \^G\-z

Note, that the input is not a valid multibyte sequence, but strvis
is supposed to handle this.

>Fix:
	

>Unformatted:
 	
 	


Home | Main Index | Thread Index | Old Index