Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Jul 2006 11:11:22 -0400 (EDT)
From:      "J.R. Oldroyd" <fbsd@opal.com>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   misc/100215: fix to hexdump(1)/od(1) following "UTF-8 zero-width character patch"
Message-ID:  <200607131511.k6DFBMQM093903@linwhf.opal.com>
Resent-Message-ID: <200607131520.k6DFKDxv085896@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         100215
>Category:       misc
>Synopsis:       fix to hexdump(1)/od(1) following "UTF-8 zero-width character patch"
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jul 13 15:20:12 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     J.R. Oldroyd
>Release:        FreeBSD 6.1-STABLE i386
>Organization:
>Environment:
System: FreeBSD linwhf.opal.com 6.1-STABLE FreeBSD 6.1-STABLE #1: Thu May 18 16:03:24 EDT 2006 xxx@linwhf.opal.com:/usr/obj/usr/src/sys/LINWHF i386

>Description:
This patch fixes a problem in hexdump(1)/od(1) which arises following
the application of the "UTF-8 zero-width character patch":
	http://www.freebsd.org/cgi/query-pr.cgi?pr=misc/100212

There is an assertion in hexdump's conv.c to verify that the width
of a character is > 0; this is no longer always the case as some
characters are actually zero width.

>How-To-Repeat:
apply "UTF-8 zero-width character patch", misc/100212
od -c file-containing-zero-width-chars, such as the utf8demo.txt file
	mentioned in that patch

The assertion will fail and od will dump core.
>Fix:
--- /usr/src/usr.bin/hexdump/conv.orig	Fri Jul 16 07:07:07 2004
+++ /usr/src/usr.bin/hexdump/conv.c	Tue Jun 27 15:20:51 2006
@@ -134,7 +134,10 @@
 			*pr->cchar = 'C';
 			assert(strcmp(pr->fmt, "%3C") == 0);
 			width = wcwidth(wc);
-			assert(width > 0);
+			if (width == 0) {
+				(void)printf(" ");
+				width = 1;
+			}
 			pad = 3 - width;
 			if (pad < 0)
 				pad = 0;


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200607131511.k6DFBMQM093903>