summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/stdio.c
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2001-10-23 22:48:00 +0000
committerache <ache@FreeBSD.org>2001-10-23 22:48:00 +0000
commit76a4ffc8e57b6461dfa6afd46f84d7dd9328ffb7 (patch)
tree30016a89c87946740b5bc95f59bf9ed664cccc5a /lib/libc/stdio/stdio.c
parentf9e1c31e422586b2016a064037860942077293ab (diff)
downloadFreeBSD-src-76a4ffc8e57b6461dfa6afd46f84d7dd9328ffb7.zip
FreeBSD-src-76a4ffc8e57b6461dfa6afd46f84d7dd9328ffb7.tar.gz
Disallow fseek() optimization in internal read buffer, if pointer is moved by
seek. It means that beginning of read buffer becomes not the same as current file position.
Diffstat (limited to 'lib/libc/stdio/stdio.c')
-rw-r--r--lib/libc/stdio/stdio.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/libc/stdio/stdio.c b/lib/libc/stdio/stdio.c
index 4bee608..c0860eb 100644
--- a/lib/libc/stdio/stdio.c
+++ b/lib/libc/stdio/stdio.c
@@ -164,6 +164,11 @@ _sseek(fp, offset, whence)
errret = errno;
if (errno == 0)
errno = serrno;
+
+ if (errret == 0 && (offset != 0 || whence != SEEK_CUR))
+ /* Disallow fseek() optimization inside read buffer */
+ fp->_flags |= __SMOD;
+
/*
* Disallow negative seeks per POSIX.
* It is needed here to help upper level caller
OpenPOWER on IntegriCloud