diff options
author | Andrey A. Chernov <ache@FreeBSD.org> | 2015-11-01 06:47:05 +0000 |
---|---|---|
committer | Andrey A. Chernov <ache@FreeBSD.org> | 2015-11-01 06:47:05 +0000 |
commit | 4fe4a788afc89d753f3cca96653279004ed9f829 (patch) | |
tree | f9a4523623049c1c770ff87267b5111ba169cb7c /lib/libc/stdio | |
parent | ec6cd152cb356dca3bea06194cec09bdea1dcf8b (diff) | |
download | src-4fe4a788afc89d753f3cca96653279004ed9f829.tar.gz src-4fe4a788afc89d753f3cca96653279004ed9f829.zip |
Addition to prev. commit.
In some edge cases fp->_p can be changed in _sseek(), recalculate.
PR: 204156
MFC after: 1 week
Notes
Notes:
svn path=/head/; revision=290231
Diffstat (limited to 'lib/libc/stdio')
-rw-r--r-- | lib/libc/stdio/ftell.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/libc/stdio/ftell.c b/lib/libc/stdio/ftell.c index 8cf94ee39c91..61ebee9ca731 100644 --- a/lib/libc/stdio/ftell.c +++ b/lib/libc/stdio/ftell.c @@ -125,10 +125,6 @@ _ftello(FILE *fp, fpos_t *offset) * underlying object. */ n = fp->_p - fp->_bf._base; - if (pos > OFF_MAX - n) { - errno = EOVERFLOW; - return (1); - } if (n > 0 && ((fp->_flags & __SAPP) || (fp->_flags2 & __S2OAP))) { int serrno = errno; @@ -147,6 +143,12 @@ _ftello(FILE *fp, fpos_t *offset) } } errno = serrno; + /* fp->_p can be changed in _sseek(), recalculate. */ + n = fp->_p - fp->_bf._base; + } + if (pos > OFF_MAX - n) { + errno = EOVERFLOW; + return (1); } pos += n; } |