NetBSD Problem Report #49871

From  Sun May  3 08:46:49 2015
Return-Path: <>
Received: from ( [])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "", Issuer "Postmaster" (not verified))
	by (Postfix) with ESMTPS id C5CD6A654C
	for <>; Sun,  3 May 2015 08:46:49 +0000 (UTC)
Message-Id: <>
Date: Sun,  3 May 2015 10:46:33 +0200 (CEST)
Subject: strunvis cannot decode strvis output
X-Send-Pr-Version: 3.95

>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
                                Michael van Elst
                                "A potential Snark may lurk in every tree."

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
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.


#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.



NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD:,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.