This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/1996] open_memstream() and seek past end of buffer
- From: "rsa at us dot ibm dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 25 Apr 2006 21:22:35 -0000
- Subject: [Bug libc/1996] open_memstream() and seek past end of buffer
- References: <20051208153314.1996.michael.kerrisk@gmx.net>
- Reply-to: sourceware-bugzilla at sourceware dot org
------- Additional Comments From rsa at us dot ibm dot com 2006-04-25 21:22 -------
Alright, found the problem.
open_memstream defines _IO_str_seekoff as the function to call when fseek() is
invoked against a stream opened with open_memstream. In:
libio/strops.c (_IO_str_seekoff)
line 275:
if (offset < 0 || (_IO_ssize_t) offset > cur_size)
return EOF;
In your case offset == 50, and cur_size == 0. Since the open_memstream()
function uses _IO_str_seekoff() and that function doesn't allow seeking beyond
the end of the data already written to the stream then this would indicate that
the documentation is wrong with regard to the current behavior.
A fix for this would be to have open_memstream() provide an overridden fseek
function which allows seeking beyond the end of the stream up to the end of the
buffer. I'm not sure this is desireable but I don't see why it isn't possible
since the beginning buffer size created by open_memstream is _G_BUFSIZE (8192).
--
http://sourceware.org/bugzilla/show_bug.cgi?id=1996
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.