This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/14292] New: fmemopen_seek() incorrectly inverses seek offset when using SEEK_END


http://sourceware.org/bugzilla/show_bug.cgi?id=14292

             Bug #: 14292
           Summary: fmemopen_seek() incorrectly inverses seek offset when
                    using SEEK_END
           Product: glibc
           Version: 2.15
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: unassigned@sourceware.org
        ReportedBy: klausman-glibc@schwarzvogel.de
                CC: drepper.fsp@gmail.com
    Classification: Unclassified


>From the fseek man page:

If whence is set to SEEK_SET, SEEK_CUR, or SEEK_END, the offset  is  relative 
to the start of the file, the current position indicator, or end-of-file,
respectively.

This leads me to believe that fseek(file, -1, SEEK_END); would seek to the
penultimate byte of file). using fseek on fopen()ened files does exactly that.

Howeverm, the fmemopen-specific implementation fseek (libio/fmemopen.c:151 has
this implementation:

    case SEEK_END:
      np = (c->binmode ? c->size : c->maxpos) - *p;
      break;

Which makes a negative offset seek forward from the end of the file (this
fails, naturally).

-- 
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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]