summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/ungetc.c
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2001-08-31 19:50:25 +0000
committerache <ache@FreeBSD.org>2001-08-31 19:50:25 +0000
commit7d962c74f05d15237307926c3a50627b99db7e0b (patch)
tree03e8d35d661564b0014d83106e783bad71d87258 /lib/libc/stdio/ungetc.c
parentf00df8355cfea7364defb72e3d4e7d06a7fe52d4 (diff)
downloadFreeBSD-src-7d962c74f05d15237307926c3a50627b99db7e0b.zip
FreeBSD-src-7d962c74f05d15237307926c3a50627b99db7e0b.tar.gz
Disallow ungetc at offset 0 (to prevent negative offset happens), so simplify
checks in ftell.
Diffstat (limited to 'lib/libc/stdio/ungetc.c')
-rw-r--r--lib/libc/stdio/ungetc.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/libc/stdio/ungetc.c b/lib/libc/stdio/ungetc.c
index f70fb42..092debd 100644
--- a/lib/libc/stdio/ungetc.c
+++ b/lib/libc/stdio/ungetc.c
@@ -132,6 +132,10 @@ __ungetc(int c, FILE *fp)
}
fp->_flags |= __SRD;
}
+
+ if (!(fp->_flags & __SSTR) && _ftello(fp) == 0)
+ return (EOF);
+
c = (unsigned char)c;
/*
OpenPOWER on IntegriCloud