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

 - todd

Index: lib/libc/stdio/fmemopen.c
===================================================================
RCS file: /cvs/src/lib/libc/stdio/fmemopen.c,v
retrieving revision 1.3
diff -u -p -u -r1.3 fmemopen.c
--- lib/libc/stdio/fmemopen.c   31 Aug 2015 02:53:57 -0000      1.3
+++ lib/libc/stdio/fmemopen.c   14 Aug 2020 01:18:39 -0000
@@ -144,7 +144,7 @@ fmemopen(void *buf, size_t size, const c
        }
 
        st->pos = 0;
-       st->len = (oflags & O_WRONLY) ? 0 : size;
+       st->len = *mode == 'w' ? 0 : size;
        st->size = size;
        st->update = oflags & O_RDWR;
 

Reply via email to