Date: Tue, 19 Aug 2008 14:37:24 +0200 (CEST) From: Johan van Selst <johans@stack.nl> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/126657: [patch] w(1) breaks multibyte date format Message-ID: <200808191237.m7JCbOlL074160@serv6.ilse.nl> Resent-Message-ID: <200808191300.m7JD09F8064335@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 126657 >Category: bin >Synopsis: [patch] w(1) breaks multibyte date format >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Aug 19 13:00:08 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Johan van Selst >Release: FreeBSD 6.3-STABLE i386 >Organization: >Environment: System: FreeBSD serv6.ilse.nl 6.3-STABLE FreeBSD 6.3-STABLE #0: Mon May 26 15:49:18 CEST 2008 root@serv6.ilse.nl:/usr/obj/usr/src/sys/SERV6 i386 >Description: w(1) uses strftime %b with to print the abbreviated month name if a user logged in more than a week ago. This may contain multibyte characters (e.g. when using UTF-8). This string is then aligned on byte-length rathern than char-length, resulting in misalignment and unfinished multibyte characters. >How-To-Repeat: If you have a user logged on for more than a week: $ env LANG=ru_RU.UTF-8 w >Fix: replace printf by wprintf (to use character length): --- w/pr_time.c 2008-08-19 14:14:03.000000000 +0200 +++ w/pr_time.c 2008-08-19 14:23:17.000000000 +0200 @@ -43,6 +43,7 @@ #include <sys/time.h> #include <stdio.h> +#include <wchar.h> #include <string.h> #include "extern.h" @@ -82,7 +83,7 @@ } (void)strftime(buf, sizeof(buf), fmt, &tp); - (void)printf("%-7.7s", buf); + (void)wprintf(L"%-7.7s", buf); } /* >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200808191237.m7JCbOlL074160>