From c0582a247f8615482f8ee7d23e92e358bbf9be80 Mon Sep 17 00:00:00 2001 From: djm Date: Sun, 17 Jul 2016 04:20:16 +0000 Subject: [PATCH] support UTF-8 characters in ssh(1) banners using schwarze@'s safe fmprintf printer; bz#2058 feedback schwarze@ ok dtucker@ --- usr.bin/ssh/ssh.c | 5 ++++- usr.bin/ssh/sshconnect2.c | 21 ++++++++------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/usr.bin/ssh/ssh.c b/usr.bin/ssh/ssh.c index b7dca7f0d00..a4a6a3591cf 100644 --- a/usr.bin/ssh/ssh.c +++ b/usr.bin/ssh/ssh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh.c,v 1.444 2016/07/16 06:57:55 jmc Exp $ */ +/* $OpenBSD: ssh.c,v 1.445 2016/07/17 04:20:16 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -62,6 +62,7 @@ #include #include #include +#include #ifdef WITH_OPENSSL #include @@ -562,6 +563,8 @@ main(int ac, char **av) */ umask(022); + setlocale(LC_CTYPE, ""); + /* * Initialize option structure to indicate that no values have been * set. diff --git a/usr.bin/ssh/sshconnect2.c b/usr.bin/ssh/sshconnect2.c index 1698b598e9e..90ff5af0618 100644 --- a/usr.bin/ssh/sshconnect2.c +++ b/usr.bin/ssh/sshconnect2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sshconnect2.c,v 1.245 2016/05/24 04:43:45 dtucker Exp $ */ +/* $OpenBSD: sshconnect2.c,v 1.246 2016/07/17 04:20:16 djm Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2008 Damien Miller. All rights reserved. @@ -65,6 +65,7 @@ #include "uidswap.h" #include "hostfile.h" #include "ssherr.h" +#include "utf8.h" #ifdef GSSAPI #include "ssh-gss.h" @@ -487,21 +488,15 @@ input_userauth_error(int type, u_int32_t seq, void *ctxt) int input_userauth_banner(int type, u_int32_t seq, void *ctxt) { - char *msg, *raw, *lang; + char *msg, *lang; u_int len; - debug3("input_userauth_banner"); - raw = packet_get_string(&len); + debug3("%s", __func__); + msg = packet_get_string(&len); lang = packet_get_string(NULL); - if (len > 0 && options.log_level >= SYSLOG_LEVEL_INFO) { - if (len > 65536) - len = 65536; - msg = xmalloc(len * 4 + 1); /* max expansion from strnvis() */ - strnvis(msg, raw, len * 4 + 1, VIS_SAFE|VIS_OCTAL|VIS_NOSLASH); - fprintf(stderr, "%s", msg); - free(msg); - } - free(raw); + if (len > 0 && options.log_level >= SYSLOG_LEVEL_INFO) + fmprintf(stderr, "%s", msg); + free(msg); free(lang); return 0; } -- 2.20.1