Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/gen strvisx is used here to encode binary data, but...



details:   https://anonhg.NetBSD.org/src/rev/27025e98e9ca
branches:  trunk
changeset: 338416:27025e98e9ca
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sat May 23 09:18:01 2015 +0000

description:
strvisx is used here to encode binary data, but the encoding
depends on locale settings and the result might not be accepted
or even misinterpreted by the strunvis decoder. As a workaround
encode manually as a string of octal numbers.

strvisx should learn how enforce such an encoding by itself.

diffstat:

 lib/libc/gen/utmpx.c |  9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diffs (33 lines):

diff -r 6e0c7241e613 -r 27025e98e9ca lib/libc/gen/utmpx.c
--- a/lib/libc/gen/utmpx.c      Sat May 23 01:45:08 2015 +0000
+++ b/lib/libc/gen/utmpx.c      Sat May 23 09:18:01 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: utmpx.c,v 1.33 2015/02/05 16:00:39 christos Exp $       */
+/*     $NetBSD: utmpx.c,v 1.34 2015/05/23 09:18:01 mlelstv Exp $        */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 #include <sys/cdefs.h>
 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: utmpx.c,v 1.33 2015/02/05 16:00:39 christos Exp $");
+__RCSID("$NetBSD: utmpx.c,v 1.34 2015/05/23 09:18:01 mlelstv Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -308,11 +308,12 @@
        char buf[sizeof(*utx) * 4 + 1];
        pid_t pid;
        int status;
+       unsigned i;
 
        _DIAGASSERT(utx != NULL);
 
-       (void)strvisx(buf, (const char *)(const void *)utx, sizeof(*utx),
-           VIS_WHITE);
+       for (i=0; i<sizeof(*utx); ++i)
+               sprintf(&buf[4*i],"\\%03o",((const char*)utx)[i]);
        switch (pid = fork()) {
        case 0:
                (void)execl(_PATH_UTMP_UPDATE,



Home | Main Index | Thread Index | Old Index