summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/stdio.c
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2001-10-24 17:25:49 +0000
committerache <ache@FreeBSD.org>2001-10-24 17:25:49 +0000
commitd21dd859f6a4af1b564c79f9848d875de721970c (patch)
treef96fc1ff02277fb89f03d5cd3347ce2e36bfdb75 /lib/libc/stdio/stdio.c
parentd34d40c8b9663341588b0ba25eff2e837974ce2c (diff)
downloadFreeBSD-src-d21dd859f6a4af1b564c79f9848d875de721970c.zip
FreeBSD-src-d21dd859f6a4af1b564c79f9848d875de721970c.tar.gz
Help to recover from bad seek (i.e. negative or too big) happens beyond
our pre-check control. Do the same way as refill.c does when it set __SERR, i.e. clear read and ungetc buffers. Clear EOF flag too.
Diffstat (limited to 'lib/libc/stdio/stdio.c')
-rw-r--r--lib/libc/stdio/stdio.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/libc/stdio/stdio.c b/lib/libc/stdio/stdio.c
index 4bee608..7f66fa8 100644
--- a/lib/libc/stdio/stdio.c
+++ b/lib/libc/stdio/stdio.c
@@ -171,6 +171,13 @@ _sseek(fp, offset, whence)
*/
if (ret < 0) {
if (errret == 0) {
+ if (offset != 0 || whence != SEEK_CUR) {
+ if (HASUB(fp))
+ FREEUB(fp);
+ fp->_p = fp->_bf._base;
+ fp->_r = 0;
+ fp->_flags &= ~__SEOF;
+ }
fp->_flags |= __SERR;
errno = EINVAL;
} else if (errret == ESPIPE)
OpenPOWER on IntegriCloud