Date: Mon, 10 Jun 2002 19:39:03 +0200 (CEST) From: Egil Brendsdal <egilb@ife.no> To: FreeBSD-gnats-submit@FreeBSD.org Cc: egilb@ife.no Subject: bin/39116: /usr/bin/printf Message-ID: <200206101739.g5AHd3472231@malurt>
next in thread | raw e-mail | index | archive | help
>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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200206101739.g5AHd3472231>
