This is the mail archive of the 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 stdio/15298] open_memstream(): seek-past-end should not change size until write

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.

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