summaryrefslogtreecommitdiff
path: root/lib/libc/stdio
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2020-08-14 12:00:34 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2020-08-14 12:00:34 +0000
commita35002c09d615b520e72c21a052180b40b761920 (patch)
tree78b2896a5d14ba959b52b2212ec979f5a4f5f0c2 /lib/libc/stdio
parent35f30a073d0265f9bfe9f92e92239607701d9246 (diff)
Fix handling of "w+" mode, we were only truncating for "w".
OK martijn@ mpi@
Diffstat (limited to 'lib/libc/stdio')
-rw-r--r--lib/libc/stdio/fmemopen.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libc/stdio/fmemopen.c b/lib/libc/stdio/fmemopen.c
index 00c27646b96..35b0ff7062a 100644
--- a/lib/libc/stdio/fmemopen.c
+++ b/lib/libc/stdio/fmemopen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fmemopen.c,v 1.3 2015/08/31 02:53:57 guenther Exp $ */
+/* $OpenBSD: fmemopen.c,v 1.4 2020/08/14 12:00:33 millert Exp $ */
/*
* Copyright (c) 2011 Martin Pieuchot <mpi@openbsd.org>
@@ -144,7 +144,7 @@ fmemopen(void *buf, size_t size, const char *mode)
}
st->pos = 0;
- st->len = (oflags & O_WRONLY) ? 0 : size;
+ st->len = (oflags & O_TRUNC) ? 0 : size;
st->size = size;
st->update = oflags & O_RDWR;