bin/126657: [patch] w(1) breaks multibyte date format
Johan van Selst
johans at stack.nl
Tue Aug 19 13:00:09 UTC 2008
>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 at 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:
More information about the freebsd-bugs
mailing list