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 libc/15298] New: open_memstream(): seek-past-end should not change size until write


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]