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.
This commit is contained in:
mlelstv 2015-05-23 09:18:01 +00:00
parent 62bd03ee9c
commit b4b5970a1f
1 changed files with 5 additions and 4 deletions

View File

@ -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. * Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -31,7 +31,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint) #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 */ #endif /* LIBC_SCCS and not lint */
#include "namespace.h" #include "namespace.h"
@ -308,11 +308,12 @@ utmp_update(const struct utmpx *utx)
char buf[sizeof(*utx) * 4 + 1]; char buf[sizeof(*utx) * 4 + 1];
pid_t pid; pid_t pid;
int status; int status;
unsigned i;
_DIAGASSERT(utx != NULL); _DIAGASSERT(utx != NULL);
(void)strvisx(buf, (const char *)(const void *)utx, sizeof(*utx), for (i=0; i<sizeof(*utx); ++i)
VIS_WHITE); sprintf(&buf[4*i],"\\%03o",((const char*)utx)[i]);
switch (pid = fork()) { switch (pid = fork()) {
case 0: case 0:
(void)execl(_PATH_UTMP_UPDATE, (void)execl(_PATH_UTMP_UPDATE,