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 stdio/10108] setvbuf _IOFBF doesn't honor size correctly


https://sourceware.org/bugzilla/show_bug.cgi?id=10108

--- Comment #9 from paxdiablo <allachan at au1 dot ibm.com> ---
I'm still not convinced that this should be considered a bug. The POSIX
standard and ISO C11 both state quite clearly (C11 has two extra words,
surrounded by [square brackets] below but the meaning is identical):
=====
If buf is not a null pointer, the array it points to MAY be used instead of a
buffer allocated by [the] setvbuf() [function] and the argument size specifies
the size of the array; otherwise, size MAY determine the size of a buffer
allocated by the setvbuf() function.
=====

Note the use of the word "may" (capitalised in my quote above). "May" and
"shall" have _very_ specific meanings in standards language, the former meaning
that something may or may not be true, the latter being that it's _required_ to
be true.

In other words, _nothing_ in POSIX or ISO (and the glibc manppage simply defers
to those standards) requires an implementation to use the buffer you pass in,
nor does it require an implementation to honor your size request.

The only way I can see this being an actual bug is if the return value is zero
even though the request is not being honoured. OP should modify their code as
per my previous comment to establish whether this is the case. However, even if
it is the case, simply returning an error would be the easiest fix :-)

-- 
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]