Date: Wed, 10 Dec 2014 08:18:23 +0000 (UTC) From: Xin LI <delphij@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r275665 - head/lib/libc/stdio Message-ID: <201412100818.sBA8INOQ028609@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: delphij Date: Wed Dec 10 08:18:22 2014 New Revision: 275665 URL: https://svnweb.freebsd.org/changeset/base/275665 Log: In r268924 __fflush was modified so that when write(2) was not successful, _p and _w are adjusted to account for the partial write (if any). However, _p and _w should not be unconditionally adjusted and should only be changed when we actually wrote some bytes, or the accumulated accounting error will eventually result in a heap buffer overflow. Reported by: adrian and alfred (Norse Corporation) Security: FreeBSD-SA-14:27.stdio Security: CVE-2014-8611 Modified: head/lib/libc/stdio/fflush.c Modified: head/lib/libc/stdio/fflush.c ============================================================================== --- head/lib/libc/stdio/fflush.c Wed Dec 10 06:43:16 2014 (r275664) +++ head/lib/libc/stdio/fflush.c Wed Dec 10 08:18:22 2014 (r275665) @@ -124,11 +124,13 @@ __sflush(FILE *fp) t = _swrite(fp, (char *)p, n); if (t <= 0) { /* Reset _p and _w. */ - if (p > fp->_p) /* Some was written. */ + if (p > fp->_p) { + /* Some was written. */ memmove(fp->_p, p, n); - fp->_p += n; - if ((fp->_flags & (__SLBF | __SNBF)) == 0) - fp->_w -= n; + fp->_p += n; + if ((fp->_flags & (__SLBF | __SNBF)) == 0) + fp->_w -= n; + } fp->_flags |= __SERR; return (EOF); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201412100818.sBA8INOQ028609>