From nobody@www.freebsd.org  Sun Jun 16 12:38:04 2002
Return-Path: <nobody@www.freebsd.org>
Received: from nwww.freebsd.org (www.FreeBSD.org [216.136.204.117])
	by hub.freebsd.org (Postfix) with ESMTP id 12CD637B42A
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 16 Jun 2002 12:38:04 -0700 (PDT)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by nwww.freebsd.org (8.12.2/8.12.2) with ESMTP id g5GJc3hG001333
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 16 Jun 2002 12:38:03 -0700 (PDT)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.2/8.12.2/Submit) id g5GJc371001332;
	Sun, 16 Jun 2002 12:38:03 -0700 (PDT)
Message-Id: <200206161938.g5GJc371001332@www.freebsd.org>
Date: Sun, 16 Jun 2002 12:38:03 -0700 (PDT)
From: Kahmyong Moon <kahmy@uclink.berkeley.edu>
To: freebsd-gnats-submit@FreeBSD.org
Subject: freopen() in libc_r does not append
X-Send-Pr-Version: www-1.0

>Number:         39377
>Category:       misc
>Synopsis:       freopen() in libc_r does not append
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jun 16 12:40:01 PDT 2002
>Closed-Date:    Thu Aug 01 04:24:24 PDT 2002
>Last-Modified:  Thu Aug 01 04:24:24 PDT 2002
>Originator:     Kahmyong Moon
>Release:        4.6
>Organization:
>Environment:
FreeBSD wormwood 4.6-RELEASE FreeBSD 4.6-RELEASE #0: Tue Jun 11 06:14
:12 GMT 2002     murray@builder.freebsdmall.com:/usr/src/sys/compile/GENERIC  i3
86
>Description:
      When compiling with libc_r, freopen() (and possibly others) do
not start writing from the end of the file, but at the beginning,
overwriting data.  A workaround is to fseek() to the end first.

Reopening standard streams may be a factor, but I don't believe so.
>How-To-Repeat:
      A simple example:

freopen("err.log", "a", stderr);
setvbuf(stderr, NULL, _IOLBF, BUFSIZ);
fputs("LOGGING INITIATIED\n", stderr);
>Fix:
      The freopen() in libc works.  Only the version in libc_r seems
to be defective.  A fix would probably be easy enough.  Do note that
I've only performed one specific test, and would not be surprised if
the other fopen() functions were also defective with regards to
append in libc_r.
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->patched 
State-Changed-By: robert 
State-Changed-When: Sun Jun 23 13:44:38 PDT 2002 
State-Changed-Why:  
A fix has been commited to -current.  Thank's for reporting the bug! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=39377 
State-Changed-From-To: patched->closed 
State-Changed-By: robert 
State-Changed-When: Thu Aug 1 04:23:45 PDT 2002 
State-Changed-Why:  
Fixed in -STABLE now as well. 

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