summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2001-09-01 14:40:01 +0000
committerache <ache@FreeBSD.org>2001-09-01 14:40:01 +0000
commit0c69b0498400f6664df5375fcebf996ba7719f42 (patch)
tree676a57eb64f3349c798379fdbbb069ed5cebc034 /lib
parentd8648337d6d5c5d7a8d79e3a94d02b694bfa67a2 (diff)
downloadFreeBSD-src-0c69b0498400f6664df5375fcebf996ba7719f42.zip
FreeBSD-src-0c69b0498400f6664df5375fcebf996ba7719f42.tar.gz
Make fseek(... SEEK_CUR) fails if current file-position is unspecified.
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/stdio/fseek.38
-rw-r--r--lib/libc/stdio/fseek.c8
2 files changed, 8 insertions, 8 deletions
diff --git a/lib/libc/stdio/fseek.3 b/lib/libc/stdio/fseek.3
index b08bbc8..fe7f313 100644
--- a/lib/libc/stdio/fseek.3
+++ b/lib/libc/stdio/fseek.3
@@ -206,12 +206,8 @@ for
and
.Fn ftell .
.It Bq Er ESPIPE
-The file descriptor underlying stream is associated with a pipe or FIFO.
-For
-.Fn ftell
-and
-.Fn ftello ,
-file-position indicator value is unspecified
+The file descriptor underlying stream is associated with a pipe or FIFO
+or file-position indicator value is unspecified
(see
.Xr ungetc 3 ) .
.El
diff --git a/lib/libc/stdio/fseek.c b/lib/libc/stdio/fseek.c
index d06e408..b2d98a9 100644
--- a/lib/libc/stdio/fseek.c
+++ b/lib/libc/stdio/fseek.c
@@ -131,8 +131,12 @@ _fseeko(fp, offset, whence, ltest)
*/
if (_ftello(fp, &curoff))
return (-1);
- if ((offset > 0 && curoff > OFF_MAX - offset) ||
- (offset < 0 && curoff < OFF_MIN - offset)) {
+ if (curoff < 0) {
+ /* Unspecified position because of ungetc() at 0 */
+ errno = ESPIPE;
+ return (-1);
+ }
+ if (offset > 0 && curoff > OFF_MAX - offset) {
errno = EOVERFLOW;
return (-1);
}
OpenPOWER on IntegriCloud