NetBSD Problem Report #40714

From www@NetBSD.org  Sun Feb 22 15:23:52 2009
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 8977D63B8EC
	for <gnats-bugs@gnats.netbsd.org>; Sun, 22 Feb 2009 15:23:52 +0000 (UTC)
Message-Id: <20090222152352.3761763B8C3@www.NetBSD.org>
Date: Sun, 22 Feb 2009 15:23:52 +0000 (UTC)
From: tnn@NetBSD.org
Reply-To: tnn@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: "%'f" works with printf(3) but not sprintf(3)
X-Send-Pr-Version: www-1.0

>Number:         40714
>Category:       lib
>Synopsis:       "%'f" works with printf(3) but not sprintf(3)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    lib-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Feb 22 15:25:00 +0000 2009
>Closed-Date:    Wed Aug 05 21:04:29 +0000 2009
>Last-Modified:  Sat Sep 05 11:45:01 +0000 2009
>Originator:     Tobias Nygren
>Release:        5.99.7 amd64
>Organization:
>Environment:
>Description:
"%'f" format specifier terminates output early when used with sprintf(3) family of functions.

>How-To-Repeat:
The second line in the output of the following program is not printed correctly.


#include <stdio.h>
int main(void) {
        char buf[128];
        printf("test: %'f\n", 123.0f);
        sprintf(buf, "test: %'f\n", 123.0f);
        printf("%s", buf);
}

> ./test
test: 123.000000
test: 1

>Fix:

>Release-Note:

>Audit-Trail:
From: Michael Stapelberg <michael+netbsd@stapelberg.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: lib/40714
Date: Mon, 13 Apr 2009 18:14:39 +0200

 Hi,

 this bug apparantly affects OpenBSD aswell. In vnstat (see pkgsrc-wip,
 wip/vnstat), the author added a workaround for OpenBSD for this issue.

 So, maybe when we fix this, someone wants to send the OpenBSD-people a patch.

 Best regards,
 Michael

From: David Laight <dsl@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/40714 CVS commit: src/lib/libc/stdio
Date: Wed, 5 Aug 2009 20:46:01 +0000

 Module Name:	src
 Committed By:	dsl
 Date:		Wed Aug  5 20:46:01 UTC 2009

 Modified Files:
 	src/lib/libc/stdio: vfwprintf.c

 Log Message:
 If the current locale doesn't define the 'thousands' grouping info
 then use sane defaults (',' every 3 digits).
 Fixes PR/40714


 To generate a diff of this commit:
 cvs rdiff -u -r1.15 -r1.16 src/lib/libc/stdio/vfwprintf.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: dsl@NetBSD.org
State-Changed-When: Wed, 05 Aug 2009 21:04:29 +0000
State-Changed-Why:
Fixed on head, pullups requested for netbsd 4 and netbsd 5


From: David Laight <david@l8s.co.uk>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: lib/40714: "%'f" works with printf(3) but not sprintf(3)
Date: Wed, 5 Aug 2009 22:02:11 +0100

 On Sun, Feb 22, 2009 at 03:25:00PM +0000, tnn@NetBSD.org wrote:
 > >Number:         40714
 > >Category:       lib
 > >Synopsis:       "%'f" works with printf(3) but not sprintf(3)

 The actual problem is that the locale stuff isn't setup, so the
 'thousands separator' is '\0' and the grouping definition isn't
 the expected "\3" (the code might actuall read from NULL).

 snprintf() is putting the \0 into the output buffer, so it gets
 truncated when passed to printf.

 	David

 -- 
 David Laight: david@l8s.co.uk

From: Manuel Bouyer <bouyer@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/40714 CVS commit: [netbsd-5] src/lib/libc/stdio
Date: Sat, 5 Sep 2009 11:38:34 +0000

 Module Name:	src
 Committed By:	bouyer
 Date:		Sat Sep  5 11:38:33 UTC 2009

 Modified Files:
 	src/lib/libc/stdio [netbsd-5]: vfwprintf.c

 Log Message:
 Pull up following revision(s) (requested by dsl in ticket #902):
 	lib/libc/stdio/vfwprintf.c: revision 1.16
 If the current locale doesn't define the 'thousands' grouping info
 then use sane defaults (',' every 3 digits).
 Fixes PR/40714


 To generate a diff of this commit:
 cvs rdiff -u -r1.13.4.1 -r1.13.4.2 src/lib/libc/stdio/vfwprintf.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: Manuel Bouyer <bouyer@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/40714 CVS commit: [netbsd-5-0] src/lib/libc/stdio
Date: Sat, 5 Sep 2009 11:40:11 +0000

 Module Name:	src
 Committed By:	bouyer
 Date:		Sat Sep  5 11:40:11 UTC 2009

 Modified Files:
 	src/lib/libc/stdio [netbsd-5-0]: vfwprintf.c

 Log Message:
 Pull up following revision(s) (requested by dsl in ticket #902):
 	lib/libc/stdio/vfwprintf.c: revision 1.16
 If the current locale doesn't define the 'thousands' grouping info
 then use sane defaults (',' every 3 digits).
 Fixes PR/40714


 To generate a diff of this commit:
 cvs rdiff -u -r1.13.4.1 -r1.13.4.1.2.1 src/lib/libc/stdio/vfwprintf.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.