Date: Sun, 1 Nov 2015 06:47:05 +0000 (UTC) From: "Andrey A. Chernov" <ache@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r290231 - head/lib/libc/stdio Message-ID: <201511010647.tA16l5Of079638@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ache Date: Sun Nov 1 06:47:05 2015 New Revision: 290231 URL: https://svnweb.freebsd.org/changeset/base/290231 Log: Addition to prev. commit. In some edge cases fp->_p can be changed in _sseek(), recalculate. PR: 204156 MFC after: 1 week Modified: head/lib/libc/stdio/ftell.c Modified: head/lib/libc/stdio/ftell.c ============================================================================== --- head/lib/libc/stdio/ftell.c Sun Nov 1 06:15:14 2015 (r290230) +++ head/lib/libc/stdio/ftell.c Sun Nov 1 06:47:05 2015 (r290231) @@ -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; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201511010647.tA16l5Of079638>