From mark@thuvia.org  Sun Aug 24 23:01:16 2003
Return-Path: <mark@thuvia.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 413C416A4BF
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 24 Aug 2003 23:01:16 -0700 (PDT)
Received: from pengo.systems.pipex.net (pengo.systems.pipex.net [62.241.160.193])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 49B2D43FB1
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 24 Aug 2003 23:01:13 -0700 (PDT)
	(envelope-from mark@thuvia.org)
Received: from dotar.thuvia.org (81-86-238-214.dsl.pipex.com [81.86.238.214])
	by pengo.systems.pipex.net (Postfix) with ESMTP id 8A1164C00A92
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 25 Aug 2003 07:01:10 +0100 (BST)
Received: from dotar.thuvia.org (localhost [127.0.0.1])
	by dotar.thuvia.org (8.12.9/8.12.9) with ESMTP id h7P61AjE054558
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 25 Aug 2003 07:01:10 +0100 (BST)
	(envelope-from mark@dotar.thuvia.org)
Received: (from mark@localhost)
	by dotar.thuvia.org (8.12.9/8.12.9/Submit) id h7P61Avj054557;
	Mon, 25 Aug 2003 07:01:10 +0100 (BST)
	(envelope-from mark)
Message-Id: <200308250601.h7P61Avj054557@dotar.thuvia.org>
Date: Mon, 25 Aug 2003 07:01:10 +0100 (BST)
From: Mark Valentine <mark@thuvia.org>
Reply-To: Mark Valentine <mark@thuvia.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: printf(1) mishandles \0
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         55947
>Category:       bin
>Synopsis:       printf(1) mishandles \0
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    stefanf@FreeBSD.org
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Aug 24 23:10:03 PDT 2003
>Closed-Date:    Sun Jul 31 12:12:31 GMT 2005
>Last-Modified:  Sun Jul 31 12:12:31 GMT 2005
>Originator:     Mark Valentine
>Release:        FreeBSD 4.8-STABLE i386
>Organization:
>Environment:
System: FreeBSD dotar.thuvia.org 4.8-STABLE FreeBSD 4.8-STABLE #6: Wed Jun 11 15:04:41 BST 2003 root@dotar.thuvia.org:/usr/obj/usr/src/sys/DOTAR i386

>Description:
printf(1) doesn't handle the sequence \0 correctly in format strings:

  $ printf 'foo\0bar' | hd
  00000000  66 6f 6f                                          |foo|
  00000003

The expected result is:

  $ printf 'foo\0bar' | hd
  00000000  66 6f 6f 00 62 61 72                              |foo.bar|
  00000007
>How-To-Repeat:
>Fix:
Borrow code from NetBSD's printf(1)...
>Release-Note:
>Audit-Trail:

From: Tim Robbins <tjr@FreeBSD.ORG>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: bin/55947
Date: Tue, 9 Sep 2003 20:16:27 +1000

 This bug is documented in the manual page. It's not easy to fix, and
 borrowing code from NetBSD would introduce more bugs.

From: Mark Valentine <mark@valentine.me.uk>
To: FreeBSD-gnats-submit@freebsd.org
Cc:  
Subject: Re: bin/55947: printf(1) mishandles \0
Date: Sat, 4 Oct 2003 02:08:29 +0000

 Just a note to mention I have a version of NetBSD's printf(1) locally with
 the FreeBSD fixes merged in (yes, it was a fair amount of work given that
 NetBSD revamped it quite a bit 10 years ago before they even moved to the
 4.4BSD code!), and a few more fixes of my own (some things it seems that
 nobody except David Korn gets right standards-wise, and he cheated!  ;-).
 
 I plan on letting the NetBSD folks look it over before I submit it here
 (and I want to do a little more work on it before that), but if anyone else
 is planning to work on this code you might want to touch base with me.
 
 I have detailed notes on my merge effort and if I don't run out of steam
 I'll try to bundle my test cases into a little regression test suite.
 
 -- 
 "Tigers will do ANYTHING for a tuna fish sandwich."
 "We're kind of stupid that way."   *munch* *munch*
   -- <http://www.calvinandhobbes.com>
State-Changed-From-To: open->patched 
State-Changed-By: stefanf 
State-Changed-When: Thu Apr 14 18:51:18 GMT 2005 
State-Changed-Why:  
A fix has been committed to -CURRENT. 


Responsible-Changed-From-To: freebsd-bugs->stefanf@FreeBSD.org 
Responsible-Changed-By: stefanf 
Responsible-Changed-When: Thu Apr 14 18:51:18 GMT 2005 
Responsible-Changed-Why:  
A fix has been committed to -CURRENT. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=55947 
State-Changed-From-To: patched->closed 
State-Changed-By: matteo 
State-Changed-When: Sun Jul 31 12:12:14 GMT 2005 
State-Changed-Why:  
Fixed and MFCed 

http://www.freebsd.org/cgi/query-pr.cgi?pr=55947 
>Unformatted:
