From ac593df8eb280317c6c3cf3013e2b2f08f75bb18 Mon Sep 17 00:00:00 2001 From: millert Date: Fri, 14 Aug 2020 12:00:33 +0000 Subject: Fix handling of "w+" mode, we were only truncating for "w". OK martijn@ mpi@ --- lib/libc/stdio/fmemopen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/libc/stdio/fmemopen.c') 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 @@ -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; -- cgit v1.2.3-59-g8ed1b