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 stdio/14292] fmemopen_seek() incorrectly inverses seek offset when using SEEK_END


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

paxdiablo <allachan at au1 dot ibm.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |allachan at au1 dot ibm.com

--- Comment #5 from paxdiablo <allachan at au1 dot ibm.com> ---
This is a definite bug and should be fixed. "Real" files use -20 with SEEK_END
to seek 20 bytes back from the end.

Author freely admitted that there may be differences between their fmemopen and
the original GNU one and that they weren't shure whether the glibc original
version suppoerted seek. But, if you're going to add it, you should do it the
way the spec says (POSIX). It clearly states that the offset is added to the
whence to get the position from file start, that means you need to seek
negative from SEEK_END to back up.

It's a "simple" (simple, assuming people haven't allowed for it) matter of
changing:

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

into:

   np = (c->binmode ? c->size : c->maxpos) + *p;

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