NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
lib/46501: Failure in fpurge.
>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;
}
Home |
Main Index |
Thread Index |
Old Index