diff options
author | ache <ache@FreeBSD.org> | 2001-10-24 17:25:49 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2001-10-24 17:25:49 +0000 |
commit | d21dd859f6a4af1b564c79f9848d875de721970c (patch) | |
tree | f96fc1ff02277fb89f03d5cd3347ce2e36bfdb75 /lib/libc/stdio/fseek.c | |
parent | d34d40c8b9663341588b0ba25eff2e837974ce2c (diff) | |
download | FreeBSD-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/fseek.c')
-rw-r--r-- | lib/libc/stdio/fseek.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/libc/stdio/fseek.c b/lib/libc/stdio/fseek.c index 2278f31..9dc8bd2 100644 --- a/lib/libc/stdio/fseek.c +++ b/lib/libc/stdio/fseek.c @@ -297,11 +297,6 @@ abspos: dumb: if (__sflush(fp) || _sseek(fp, (fpos_t)offset, whence) == POS_ERR) return (-1); - if (ltest && fp->_offset > LONG_MAX) { - fp->_flags |= __SERR; - errno = EOVERFLOW; - return (-1); - } /* success: clear EOF indicator and discard ungetc() data */ if (HASUB(fp)) FREEUB(fp); @@ -309,5 +304,10 @@ dumb: fp->_r = 0; /* fp->_w = 0; */ /* unnecessary (I think...) */ fp->_flags &= ~__SEOF; + if (ltest && fp->_offset > LONG_MAX) { + fp->_flags |= __SERR; + errno = EOVERFLOW; + return (-1); + } return (0); } |