public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/15298] New: open_memstream(): seek-past-end should not change size until write
@ 2013-03-23  4:40 guenther at gmail dot com
  2013-03-23  4:58 ` [Bug libc/15298] " guenther at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: guenther at gmail dot com @ 2013-03-23  4:40 UTC (permalink / raw)
  To: glibc-bugs

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

             Bug #: 15298
           Summary: open_memstream(): seek-past-end should not change size
                    until write
           Product: glibc
           Version: 2.17
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: unassigned@sourceware.org
        ReportedBy: guenther@gmail.com
                CC: drepper.fsp@gmail.com
    Classification: Unclassified


Created attachment 6941
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6941
partial regression test for open_memstream

The IEEE Std 1003.1-2008 (aka POSIX-2008) says this in its description of
open_memstream:
--------
The stream shall maintain a current position in the allocated buffer and a
current buffer length. The position shall be initially set to zero (the start
of the buffer). Each write to the stream shall start at the current position
and move this position by the number of successfully written bytes for
open_memstream() or the number of successfully written wide characters for
open_wmemstream(). The length shall be initially set to zero. If a write moves
the position to a value larger than the current length, the current length
shall be set to this position. In this case a null character for
open_memstream() or a null wide character for open_wmemstream() shall be
appended to the current buffer. For both functions the terminating null is not
included in the calculation of the buffer length.

After a successful fflush() or fclose(), the pointer referenced by bufp shall
contain the address of the buffer, and the variable pointed to by sizep shall
contain the smaller of the current buffer length and the number of bytes for
open_memstream(), or the number of wide characters for open_wmemstream(),
between the beginning of the buffer and the current file position indicator.
--------

So, if you write to the stream, seek past the end, then close it without
writing again, the size location should be set to the end of the furthest write
("smaller of the current buffer length and <...>"), not the seek position.  In
glibc 2.17, it instead returns the seek position.

-- 
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] 6+ messages in thread

end of thread, other threads:[~2020-06-24 15:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-23  4:40 [Bug libc/15298] New: open_memstream(): seek-past-end should not change size until write guenther at gmail dot com
2013-03-23  4:58 ` [Bug libc/15298] " guenther at gmail dot com
2013-03-23  5:34 ` guenther at gmail dot com
2014-06-13 18:41 ` fweimer at redhat dot com
2015-08-22 20:34 ` [Bug stdio/15298] " jsm28 at gcc dot gnu.org
2020-06-24 15:57 ` tonyb at cybernetics dot com

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