summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>2001-10-24 17:25:49 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>2001-10-24 17:25:49 +0000
commite41febc84bf8630e945f4e839c04fde106509681 (patch)
treef96fc1ff02277fb89f03d5cd3347ce2e36bfdb75
parenta55dfa2ac19ccc2fafacabc5d382b4f5e0ff5391 (diff)
Notes
-rw-r--r--lib/libc/stdio/fseek.c10
-rw-r--r--lib/libc/stdio/stdio.c7
2 files changed, 12 insertions, 5 deletions
diff --git a/lib/libc/stdio/fseek.c b/lib/libc/stdio/fseek.c
index 2278f311ea9d..9dc8bd28275f 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);
}
diff --git a/lib/libc/stdio/stdio.c b/lib/libc/stdio/stdio.c
index 4bee60804d4a..7f66fa8ab591 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)