From owner-freebsd-bugs@FreeBSD.ORG Sat Mar 24 01:00:25 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EB7711065674 for ; Sat, 24 Mar 2012 01:00:25 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 34C1E8FC15 for ; Sat, 24 Mar 2012 01:00:16 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q2O10G28061711 for ; Sat, 24 Mar 2012 01:00:16 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q2O10Gxl061710; Sat, 24 Mar 2012 01:00:16 GMT (envelope-from gnats) Resent-Date: Sat, 24 Mar 2012 01:00:16 GMT Resent-Message-Id: <201203240100.q2O10Gxl061710@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, "J.R. Oldroyd" Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 28779106564A for ; Sat, 24 Mar 2012 00:56:59 +0000 (UTC) (envelope-from jr@opal.com) Received: from mho-01-ewr.mailhop.org (mho-01-ewr.mailhop.org [204.13.248.71]) by mx1.freebsd.org (Postfix) with ESMTP id CAEC38FC0A for ; Sat, 24 Mar 2012 00:56:58 +0000 (UTC) Received: from pool-151-203-193-46.bos.east.verizon.net ([151.203.193.46] helo=homobox.opal.com) by mho-01-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1SBEnM-000D8H-0T for FreeBSD-gnats-submit@freebsd.org; Sat, 24 Mar 2012 00:25:24 +0000 Received: from opal.com (localhost [IPv6:::1]) (authenticated bits=0) by homobox.opal.com (8.14.4/8.14.4) with ESMTP id q2O0PL5J003813 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 23 Mar 2012 20:25:22 -0400 (EDT) (envelope-from jr@opal.com) Received: from shibato.opal.com ([2001:470:8cb8:3:221:63ff:fe5a:c9a7] helo=shibato.opal.com) with IPv6:587 by opal.com; 23 Mar 2012 20:25:21 -0400 Received: from shibato.opal.com (localhost [127.0.0.1]) by shibato.opal.com (8.14.4/8.14.4) with ESMTP id q2O0PLOg006601 for ; Fri, 23 Mar 2012 20:25:21 -0400 (EDT) (envelope-from jr@opal.com) Received: (from jr@localhost) by shibato.opal.com (8.14.4/8.14.4/Submit) id q2O0PLVN006600; Fri, 23 Mar 2012 20:25:21 -0400 (EDT) (envelope-from jr) Message-Id: <201203240025.q2O0PLVN006600@shibato.opal.com> Date: Fri, 23 Mar 2012 20:25:21 -0400 (EDT) From: "J.R. Oldroyd" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/166364: make ps(1) display 8-bit characters as such X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: "J.R. Oldroyd" List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Mar 2012 01:00:26 -0000 >Number: 166364 >Category: bin >Synopsis: make ps(1) display 8-bit characters as such >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: Sat Mar 24 01:00:15 UTC 2012 >Closed-Date: >Last-Modified: >Originator: J.R. Oldroyd >Release: FreeBSD 8.2-RELEASE amd64 >Organization: >Environment: System: FreeBSD xx.opal.com 8.2-RELEASE FreeBSD 8.2-RELEASE #0: Thu Feb 17 02:41:51 UTC 2011 root@mason.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64 >Description: Currently, ps(1) uses strvis(3) to pretty-up all commands and arguments before they are displayed. This has the detrimental effect of converting 8-bit characters in command names and argument lists to sequences such as "\M-C\M-)" for a simple "é" (e-acute), etc, thereby making ps' output very awkward for those of us that work in languages that use 8-bit characters. These sequences are not human-readable, nor is it possible to cut and paste such words back to the command line. It is unclear why strvis() is used here, but it exists in the ps(1) source from the earliest version in svn. If strvis() is no longer needed here, it should be removed, or at the least replaced with code that removes "dangerous" characters (whatever they may be) but which leaves 8-bit alphabetics alone. The attached diff removes the four strvis() calls and replaces them with strcpy(). A cleaner solution would rework the associated code to no longer need the copy at all, by using the "src" variable in place of the "dst" one in the code following and so eliminating the need for the "dst" variable. For comparison, procstat(1) does not do any pretty-printing of command names or arguments in this way. >How-To-Repeat: 1. Run any command that has any 8-bit character in its name or any argument. 2. Run "ps ax" while that command is running and examine the ps output. >Fix: --- fmt.oc 2011-02-22 12:25:38.000000000 -0500 +++ fmt.c 2012-03-23 20:07:23.000000000 -0400 @@ -47,7 +47,6 @@ #include #include #include -#include #include "ps.h" @@ -82,8 +81,7 @@ if (*src == '\0') continue; len = (buf_size - 1 - (dst - buf)) / 4; - strvisx(dst, src, strlen(src) < len ? strlen(src) : len, - VIS_NL | VIS_CSTYLE); + strcpy(dst, src); while (*dst != '\0') dst++; if ((buf_size - 1 - (dst - buf)) / 4 > 0) --- print.oc 2011-02-22 12:25:38.000000000 -0500 +++ print.c 2012-03-23 20:07:57.000000000 -0400 @@ -58,7 +58,6 @@ #include #include #include -#include #include "ps.h" @@ -101,7 +100,7 @@ v = ve->var; if ((vis_args = malloc(strlen(k->ki_args) * 4 + 1)) == NULL) errx(1, "malloc failed"); - strvis(vis_args, k->ki_args, VIS_TAB | VIS_NL | VIS_NOSLASH); + strcpy(vis_args, k->ki_args); if (STAILQ_NEXT(ve, next_ve) == NULL) { /* last field */ if (termwidth == UNLIMITED) { @@ -141,7 +140,7 @@ } if ((vis_args = malloc(strlen(k->ki_args) * 4 + 1)) == NULL) errx(1, "malloc failed"); - strvis(vis_args, k->ki_args, VIS_TAB | VIS_NL | VIS_NOSLASH); + strcpy(vis_args, k->ki_args); if (STAILQ_NEXT(ve, next_ve) == NULL) { /* last field */ @@ -150,8 +149,7 @@ if ((vis_env = malloc(strlen(k->ki_env) * 4 + 1)) == NULL) errx(1, "malloc failed"); - strvis(vis_env, k->ki_env, - VIS_TAB | VIS_NL | VIS_NOSLASH); + strcpy(vis_env, k->ki_env); } else vis_env = NULL; >Release-Note: >Audit-Trail: >Unformatted: