On 2020-08-14 01:44, Todd C. Miller wrote:
On Thu, 13 Aug 2020 19:31:04 -0600, Todd C. Miller wrote:

The fix is to look at mode, not oflags since "w+" will set O_RDWR,
not O_WRONLY.

Actually, checking O_TRUNC is probably better and is consistent
with the rest of the code.  Either diff produces the expected results
from your test program.

FreeBSD checks mode[0] rather than oflags, I don't know if it is better to
do this way.

Also, is size for *mode == 'a' handled correctly?
I don't know fmemopen(3) very well to understand how it should work. I have just been introduced to this function in APUE (Advanced Programming in the
UNIX Environment), section 5.14.  The code is a snippet from the book.

[0]: https://github.com/freebsd/freebsd/blob/master/lib/libc/stdio/fmemopen.c#L118

Reply via email to