bin/55947: printf(1) mishandles \0

Mark Valentine mark at thuvia.org
Sun Aug 24 23:10:04 PDT 2003


>Number:         55947
>Category:       bin
>Synopsis:       printf(1) mishandles \0
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Aug 24 23:10:03 PDT 2003
>Closed-Date:
>Last-Modified:
>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 at 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:
>Unformatted:


More information about the freebsd-bugs mailing list