This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug stdio/14543] New: fseek sets invalid status in the internal buffer in wide mode
- From: "siddhesh at redhat dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: Tue, 04 Sep 2012 15:52:40 +0000
- Subject: [Bug stdio/14543] New: fseek sets invalid status in the internal buffer in wide mode
- Auto-submitted: auto-generated
http://sourceware.org/bugzilla/show_bug.cgi?id=14543
Bug #: 14543
Summary: fseek sets invalid status in the internal buffer in
wide mode
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: stdio
AssignedTo: unassigned@sourceware.org
ReportedBy: siddhesh@redhat.com
Classification: Unclassified
fseek sets the pointers in the external buffer correctly, but initializes the
internal buffer as if there's nothing in it. As a result, the position computed
in a subsequent ftell is incorrect.
How Reproducible:
Always
Reproducer program:
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
int main(int argc, char** argv)
{
FILE *fp;
setlocale(LC_ALL, "en_US.utf8");
fp = fopen("output.txt", "w+");
if (fp == NULL) {
perror("fopen");
exit(1);
}
if (fputws(L"abc\n", fp) == -1) {
perror("fputws");
exit(1);
}
printf("before=%d\n", ftell(fp));
rewind (fp);
if (fseek(fp, 0L, SEEK_END) == -1) {
perror("fseek");
exit(1);
}
printf("fseek=%d\n", ftell(fp));
if (fputws(L"xyz\n", fp) == -1) {
perror("fputws");
exit(1);
}
printf("after=%d\n", ftell(fp));
fclose(fp);
}
Actual result:
before=4
fseek=0
after=4
Expected Result:
before=4
fseek=4
after=8
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.