public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug stdio/14543] New: fseek sets invalid status in the internal buffer in wide mode
@ 2012-09-04 15:52 siddhesh at redhat dot com
  2012-09-04 15:54 ` [Bug stdio/14543] " siddhesh at redhat dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: siddhesh at redhat dot com @ 2012-09-04 15:52 UTC (permalink / raw)
  To: glibc-bugs

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.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-06-17  4:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-04 15:52 [Bug stdio/14543] New: fseek sets invalid status in the internal buffer in wide mode siddhesh at redhat dot com
2012-09-04 15:54 ` [Bug stdio/14543] " siddhesh at redhat dot com
2012-09-13 14:16 ` siddhesh at redhat dot com
2012-09-28 13:31 ` siddhesh at redhat dot com
2014-06-17  4:46 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).