From owner-freebsd-bugs Mon Jun 10 10:40:13 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 03EE237B406 for ; Mon, 10 Jun 2002 10:40:03 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g5AHe2A84939; Mon, 10 Jun 2002 10:40:02 -0700 (PDT) (envelope-from gnats) Received: from barney.ife.no (barney.ife.no [128.39.229.49]) by hub.freebsd.org (Postfix) with ESMTP id 5107B37B405 for ; Mon, 10 Jun 2002 10:39:07 -0700 (PDT) Received: from malurt (malurt.ife.no [128.39.229.54]) by barney.ife.no (8.9.3/8.9.3) with ESMTP id TAA29862; Mon, 10 Jun 2002 19:39:03 +0200 (MET DST) Received: by malurt ; Mon, 10 Jun 2002 19:39:03 +0200 (CEST) Message-Id: <200206101739.g5AHd3472231@malurt> Date: Mon, 10 Jun 2002 19:39:03 +0200 (CEST) From: Egil Brendsdal Reply-To: egilb@ife.no To: FreeBSD-gnats-submit@FreeBSD.org Cc: egilb@ife.no X-Send-Pr-Version: 3.113 Subject: bin/39116: /usr/bin/printf Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 39116 >Category: bin >Synopsis: /usr/bin/printf >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Jun 10 10:40:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Egil Brendsdal >Release: FreeBSD 4.4-RELEASE i386 >Organization: >Environment: System: FreeBSD malurt.ife.no 4.4-RELEASE FreeBSD 4.4-RELEASE #1: Thu Oct 18 11:11:12 CEST 2001 root@malurt.ife.no:/usr/src/sys/compile/MALURT i386 >Description: 1) printf fails on \45 and multiple %% in the format string. 2) Field width specified by * gives unpredictable result. >How-To-Repeat: /usr/bin/printf, 4.4-RELEASE: egilb@malurt 101 % ident /usr/bin/printf /usr/bin/printf: $FreeBSD: src/usr.bin/printf/printf.c,v 1.12.6.4 2001/03/04 08:55:53 kris Exp $ egilb@malurt 102 % /usr/bin/printf '\45\n' printf: illegal format character egilb@malurt 103 % /usr/bin/printf '%%%s\n' a b c %a printf: illegal format character % egilb@malurt 104 % /usr/bin/printf '%*i\n' 8589934592 Current version of printf from CVS: egilb@malurt 101 % ident ./printf ./printf: $FreeBSD: src/usr.bin/printf/printf.c,v 1.21 2002/04/25 01:10:11 tjr Exp $ egilb@malurt 102 % ./printf '\45\n' printf: illegal format character egilb@malurt 103 % egilb@malurt 103 % ./printf '%%%s\n' a b c %a printf: illegal format character % egilb@malurt 104 % ./printf '%*i\n' 8589934592 >Fix: The source code of an alternative implementation of printf is available upon request. Using this program, the result of the reported tests are: egilb@malurt 101 % my_printf '\45\n' % egilb@malurt 102 % my_printf '%%%s\n' a b c %a %b %c egilb@malurt 103 % my_printf '%*i\n' 0 In addition, the bug due to internal zero-termination of the format string is solved: egilb@malurt 104 % my_printf '\2\1\0\1\2' | od -c 0000000 002 001 \0 001 002 0000005 >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message