public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/14292] New: fmemopen_seek() incorrectly inverses seek offset when using SEEK_END
@ 2012-06-25 14:56 klausman-glibc at schwarzvogel dot de
  2012-08-13  8:27 ` [Bug libc/14292] " klausman-glibc at schwarzvogel dot de
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: klausman-glibc at schwarzvogel dot de @ 2012-06-25 14:56 UTC (permalink / raw)
  To: glibc-bugs

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.


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

end of thread, other threads:[~2015-07-08 15:17 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-25 14:56 [Bug libc/14292] New: fmemopen_seek() incorrectly inverses seek offset when using SEEK_END klausman-glibc at schwarzvogel dot de
2012-08-13  8:27 ` [Bug libc/14292] " klausman-glibc at schwarzvogel dot de
2012-12-27 21:27 ` klausman-glibc at schwarzvogel dot de
2012-12-27 21:28 ` klausman-glibc at schwarzvogel dot de
2013-01-25 15:28 ` [Bug stdio/14292] " klausman-glibc at schwarzvogel dot de
2013-06-25 13:33 ` klausman-glibc at schwarzvogel dot de
2013-08-13  7:33 ` klausman-glibc at schwarzvogel dot de
2013-08-13  7:50 ` klausman-glibc at schwarzvogel dot de
2014-01-30  5:32 ` allachan at au1 dot ibm.com
2014-01-30  5:42 ` allachan at au1 dot ibm.com
2014-01-30  8:09 ` allachan at au1 dot ibm.com
2014-03-24 11:55 ` klausman-glibc at schwarzvogel dot de
2014-06-13 14:04 ` fweimer at redhat dot com
2015-07-08 15:17 ` adhemerval.zanella at linaro dot org

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