NetBSD Problem Report #46501

From www@NetBSD.org  Wed May 30 10:59:41 2012
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id E46BA63B88D
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 30 May 2012 10:59:40 +0000 (UTC)
Message-Id: <20120530105940.4855163B882@www.NetBSD.org>
Date: Wed, 30 May 2012 10:59:40 +0000 (UTC)
From: henning.petersen@t-online.de
Reply-To: henning.petersen@t-online.de
To: gnats-bugs@NetBSD.org
Subject: Failure in fpurge.
X-Send-Pr-Version: www-1.0

>Number:         46501
>Category:       lib
>Synopsis:       Failure in fpurge.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed May 30 11:00:00 +0000 2012
>Originator:     Henning Petersen
>Release:        NetBSD-current
>Organization:
>Environment:
>Description:
Test programm is writing "abc" in file "bar", it should be "abcd".
With the patch taken from FreeBSD it is correct.
>How-To-Repeat:
With this test I got "abc".

#include <stdio.h>
#include <stdlib.h>

int main (int argc, char **argv)
{
FILE *f = fopen("bar", "w+");
fputs ("abc", f);
rewind (f);
while (EOF != fgetc (f));
fpurge (f);
argc > 1 ? putc ('d', f) : fputc ('d', f);
return 0;
}

>Fix:
diff -u -p -r1.14 fpurge.c
--- lib/libc/stdio/fpurge.c	15 Mar 2012 18:22:30 -0000	1.14
+++ lib/libc/stdio/fpurge.c	30 May 2012 09:06:57 -0000
@@ -69,7 +69,7 @@ fpurge(FILE *fp)
 	WCIO_FREE(fp);
 	fp->_p = fp->_bf._base;
 	fp->_r = 0;
-	fp->_w = fp->_flags & (__SLBF|__SNBF) ? 0 : fp->_bf._size;
+	fp->_w = fp->_flags & (__SLBF|__SNBF|__SRD) ? 0 : fp->_bf._size;
 	FUNLOCKFILE(fp);
 	return 0;
 }

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.