This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug stdio/15298] open_memstream(): seek-past-end should not change size until write
- From: "adhemerval.zanella at linaro dot org" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Thu, 04 Aug 2016 19:03:09 +0000
- Subject: [Bug stdio/15298] open_memstream(): seek-past-end should not change size until write
- Auto-submitted: auto-generated
- References: <bug-15298-131@http.sourceware.org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=15298
Adhemerval Zanella <adhemerval.zanella at linaro dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |adhemerval.zanella at linaro dot o
| |rg
--- Comment #2 from Adhemerval Zanella <adhemerval.zanella at linaro dot org> ---
I agree that returned size from fflush/fclose on a open_memstream FILE is not
correct for current GLIBC code. As stated in first comment, final size is
being based on current buffer position defined by fseek instead of current
minimum size from written bytes.
However, the provided testcase also are not correct:
134 if (size != OFFSET + sizeof(hello)-1) {
135 warnx("failed, size %zu should be %lu. (18)",
136 size, (unsigned long)(OFFSET + sizeof(hello)-1));
137 failures++;
138 }
The final size should be '5', not 16389 because there is not write operation
between fflush at line 95 and final fclose at line 129. Recall that fseek at
line 124 would move the internal position, but according to POSIX "the
variable pointed to by sizep shall contain the *smaller* of the current buffer
length and the number of bytes".
I am working on correcting this issue and other open_memstream issues (BZ#18241
and BZ#20181).
--
You are receiving this mail because:
You are on the CC list for the bug.