From johans@serv6.ilse.nl  Tue Aug 19 12:52:59 2008
Return-Path: <johans@serv6.ilse.nl>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id BFA081065676
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 19 Aug 2008 12:52:59 +0000 (UTC)
	(envelope-from johans@serv6.ilse.nl)
Received: from serv6.ilse.nl (nat.sux.experimental.net [62.69.160.1])
	by mx1.freebsd.org (Postfix) with ESMTP id 2B1248FC0C
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 19 Aug 2008 12:52:58 +0000 (UTC)
	(envelope-from johans@serv6.ilse.nl)
Received: from serv6.ilse.nl (localhost [127.0.0.1])
	by serv6.ilse.nl (8.14.2/8.14.2) with ESMTP id m7JCbOoP074161
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 19 Aug 2008 14:37:24 +0200 (CEST)
	(envelope-from johans@serv6.ilse.nl)
Received: (from johans@localhost)
	by serv6.ilse.nl (8.14.2/8.14.2/Submit) id m7JCbOlL074160;
	Tue, 19 Aug 2008 14:37:24 +0200 (CEST)
	(envelope-from johans)
Message-Id: <200808191237.m7JCbOlL074160@serv6.ilse.nl>
Date: Tue, 19 Aug 2008 14:37:24 +0200 (CEST)
From: Johan van Selst <johans@stack.nl>
Reply-To: Johan van Selst <johans@stack.nl>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] w(1) breaks multibyte date format
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         126657
>Category:       bin
>Synopsis:       [patch] w(1) breaks multibyte date format
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Aug 19 13:00:08 UTC 2008
>Closed-Date:    Fri Nov 02 22:15:41 UTC 2012
>Last-Modified:  Fri Nov 02 22:15:41 UTC 2012
>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:
State-Changed-From-To: open->patched 
State-Changed-By: ache 
State-Changed-When: Wed Aug 20 12:33:12 UTC 2008 
State-Changed-Why:  
Committed into -current 

http://www.freebsd.org/cgi/query-pr.cgi?pr=126657 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/126657: commit references a PR
Date: Wed, 20 Aug 2008 12:32:45 +0000 (UTC)

 ache        2008-08-20 12:32:19 UTC
 
   FreeBSD src repository
 
   Modified files:
     usr.bin/w            pr_time.c 
   Log:
   SVN rev 181922 on 2008-08-20 12:32:19Z by ache
   
   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.
   
   PR:             126657
   Submitted by:   Johan van Selst <johans@stack.nl>
   
   Revision  Changes    Path
   1.20      +2 -1      src/usr.bin/w/pr_time.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
Responsible-Changed-From-To: freebsd-bugs->ache 
Responsible-Changed-By: vwe 
Responsible-Changed-When: Sat Jan 3 23:09:18 UTC 2009 
Responsible-Changed-Why:  
reassign to ache for MFC who committed the patch into HEAD 

http://www.freebsd.org/cgi/query-pr.cgi?pr=126657 
Responsible-Changed-From-To: ache->freebsd-bugs 
Responsible-Changed-By: ache 
Responsible-Changed-When: Sun Jan 4 19:03:11 UTC 2009 
Responsible-Changed-Why:  
Please don't reassign to me, I don't have any non-current machine with  
convenient access to test MFC. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=126657 
State-Changed-From-To: patched->closed 
State-Changed-By: eadler 
State-Changed-When: Fri Nov 2 22:15:39 UTC 2012 
State-Changed-Why:  
MFCed/fixed by now 

http://www.freebsd.org/cgi/query-pr.cgi?pr=126657 
>Unformatted:
