From owner-svn-src-stable@FreeBSD.ORG Sun Jan 1 19:15:53 2012 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7665C106566C; Sun, 1 Jan 2012 19:15:53 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6107D8FC15; Sun, 1 Jan 2012 19:15:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q01JFrVb026744; Sun, 1 Jan 2012 19:15:53 GMT (envelope-from dim@svn.freebsd.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q01JFrl6026742; Sun, 1 Jan 2012 19:15:53 GMT (envelope-from dim@svn.freebsd.org) Message-Id: <201201011915.q01JFrl6026742@svn.freebsd.org> From: Dimitry Andric Date: Sun, 1 Jan 2012 19:15:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r229192 - stable/9/usr.bin/hexdump X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Jan 2012 19:15:53 -0000 Author: dim Date: Sun Jan 1 19:15:52 2012 New Revision: 229192 URL: http://svn.freebsd.org/changeset/base/229192 Log: MFC r228636: Correct a logic error in usr.bin/hexdump/conv.c, found by clang. Whenever the conv_c() function encounters an incomplete multibyte char, it peeks ahead. It also sets p to peekbuf, to indicate it is still processing the incomplete character. However, on the next retry, it compares buf against peekbuf, which always returns false, since both buf and peekbuf are local char arrays, whose addresses are never the same. Fix this by comparing against p instead, which was the intention. Also turn peekbuf into an array of u_char, to prevent conversion warnings. Modified: stable/9/usr.bin/hexdump/conv.c Directory Properties: stable/9/usr.bin/hexdump/ (props changed) Modified: stable/9/usr.bin/hexdump/conv.c ============================================================================== --- stable/9/usr.bin/hexdump/conv.c Sun Jan 1 19:12:07 2012 (r229191) +++ stable/9/usr.bin/hexdump/conv.c Sun Jan 1 19:15:52 2012 (r229192) @@ -53,7 +53,7 @@ conv_c(PR *pr, u_char *p, size_t bufsize wchar_t wc; size_t clen, oclen; int converr, pad, width; - char peekbuf[MB_LEN_MAX]; + u_char peekbuf[MB_LEN_MAX]; if (pr->mbleft > 0) { str = "**"; @@ -103,7 +103,7 @@ retry: if (clen == 0) clen = 1; else if (clen == (size_t)-1 || (clen == (size_t)-2 && - buf == peekbuf)) { + p == peekbuf)) { memset(&pr->mbstate, 0, sizeof(pr->mbstate)); wc = *p; clen = 1;