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
* [Bug libc/14292] fmemopen_seek() incorrectly inverses seek offset when using SEEK_END
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 ` klausman-glibc at schwarzvogel dot de
2012-12-27 21:27 ` klausman-glibc at schwarzvogel dot de
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: klausman-glibc at schwarzvogel dot de @ 2012-08-13 8:27 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=14292
Tobias Klausmann <klausman-glibc at schwarzvogel dot de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Version|2.15 |2.16
--- Comment #1 from Tobias Klausmann <klausman-glibc at schwarzvogel dot de> 2012-08-13 08:27:24 UTC ---
This is also present in 2.16
--
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
* [Bug libc/14292] fmemopen_seek() incorrectly inverses seek offset when using SEEK_END
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
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: klausman-glibc at schwarzvogel dot de @ 2012-12-27 21:27 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=14292
Tobias Klausmann <klausman-glibc at schwarzvogel dot de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Version|2.16 |2.17
--
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
* [Bug libc/14292] fmemopen_seek() incorrectly inverses seek offset when using SEEK_END
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
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: klausman-glibc at schwarzvogel dot de @ 2012-12-27 21:28 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=14292
--- Comment #2 from Tobias Klausmann <klausman-glibc at schwarzvogel dot de> 2012-12-27 21:28:02 UTC ---
... and in 2.17
--
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
* [Bug stdio/14292] fmemopen_seek() incorrectly inverses seek offset when using SEEK_END
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
` (2 preceding siblings ...)
2012-12-27 21:28 ` klausman-glibc at schwarzvogel dot de
@ 2013-01-25 15:28 ` klausman-glibc at schwarzvogel dot de
2013-06-25 13:33 ` klausman-glibc at schwarzvogel dot de
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: klausman-glibc at schwarzvogel dot de @ 2013-01-25 15:28 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=14292
Tobias Klausmann <klausman-glibc at schwarzvogel dot de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|libc |stdio
--
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
* [Bug stdio/14292] fmemopen_seek() incorrectly inverses seek offset when using SEEK_END
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
` (3 preceding siblings ...)
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
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: klausman-glibc at schwarzvogel dot de @ 2013-06-25 13:33 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=14292
--- Comment #3 from Tobias Klausmann <klausman-glibc at schwarzvogel dot de> ---
HAppy birthday, dear trivial bug.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug stdio/14292] fmemopen_seek() incorrectly inverses seek offset when using SEEK_END
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
` (4 preceding siblings ...)
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
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: klausman-glibc at schwarzvogel dot de @ 2013-08-13 7:33 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=14292
--- Comment #4 from Tobias Klausmann <klausman-glibc at schwarzvogel dot de> ---
And it's in 2.18, too.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug stdio/14292] fmemopen_seek() incorrectly inverses seek offset when using SEEK_END
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
` (5 preceding siblings ...)
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
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: klausman-glibc at schwarzvogel dot de @ 2013-08-13 7:50 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=14292
Tobias Klausmann <klausman-glibc at schwarzvogel dot de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Version|2.17 |2.18
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug stdio/14292] fmemopen_seek() incorrectly inverses seek offset when using SEEK_END
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
` (6 preceding siblings ...)
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
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: allachan at au1 dot ibm.com @ 2014-01-30 5:32 UTC (permalink / raw)
To: glibc-bugs
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.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug stdio/14292] fmemopen_seek() incorrectly inverses seek offset when using SEEK_END
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
` (7 preceding siblings ...)
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
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: allachan at au1 dot ibm.com @ 2014-01-30 5:42 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=14292
paxdiablo <allachan at au1 dot ibm.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P2 |P1
Severity|normal |critical
--- Comment #6 from paxdiablo <allachan at au1 dot ibm.com> ---
Upgrading importance since it dfoesn't conform to ISO C. Reasoning is that it
changes how fseek() works depending on underlying "file" type.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug stdio/14292] fmemopen_seek() incorrectly inverses seek offset when using SEEK_END
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
` (8 preceding siblings ...)
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
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: allachan at au1 dot ibm.com @ 2014-01-30 8:09 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=14292
--- Comment #7 from paxdiablo <allachan at au1 dot ibm.com> ---
FWIW, this bug has been there since about 2001. glibc-2.1.3 from Feb-2000 had
the old implementation in stdio which didn't support fseek at all.
In Jan-2001, glibc-2.2.1 incorporated the new code into libio and it already
had that bug.
I can only assume that the fact no-one noticed for over a decade is because
no-one has ever used it :-)
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug stdio/14292] fmemopen_seek() incorrectly inverses seek offset when using SEEK_END
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
` (9 preceding siblings ...)
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
12 siblings, 0 replies; 14+ messages in thread
From: klausman-glibc at schwarzvogel dot de @ 2014-03-24 11:55 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=14292
Tobias Klausmann <klausman-glibc at schwarzvogel dot de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Version|2.18 |2.19
--- Comment #8 from Tobias Klausmann <klausman-glibc at schwarzvogel dot de> ---
Also present in 2.19
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug stdio/14292] fmemopen_seek() incorrectly inverses seek offset when using SEEK_END
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
` (10 preceding siblings ...)
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
12 siblings, 0 replies; 14+ messages in thread
From: fweimer at redhat dot com @ 2014-06-13 14:04 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=14292
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fweimer at redhat dot com
Flags| |security-
--- Comment #9 from Florian Weimer <fweimer at redhat dot com> ---
Marking as no security impact because there are apparently have not been any
users of this function.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug stdio/14292] fmemopen_seek() incorrectly inverses seek offset when using SEEK_END
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
` (11 preceding siblings ...)
2014-06-13 14:04 ` fweimer at redhat dot com
@ 2015-07-08 15:17 ` adhemerval.zanella at linaro dot org
12 siblings, 0 replies; 14+ messages in thread
From: adhemerval.zanella at linaro dot org @ 2015-07-08 15:17 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=14292
Adhemerval Zanella <adhemerval.zanella at linaro dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |adhemerval.zanella at linaro dot o
| |rg
Resolution|--- |FIXED
--- Comment #10 from Adhemerval Zanella <adhemerval.zanella at linaro dot org> ---
This is fixed by fdb7d390dd0d96e4a8239c46f3aa64598b90842b. Closing this bug.
--
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).