Date: Sun, 10 Feb 2013 23:09:15 +0000 (UTC) From: Jilles Tjoelker <jilles@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r246641 - head/lib/libc/gen Message-ID: <201302102309.r1AN9FZ3047020@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jilles Date: Sun Feb 10 23:09:15 2013 New Revision: 246641 URL: http://svnweb.freebsd.org/changeset/base/246641 Log: fts: Use O_DIRECTORY when opening name that might be changed by attacker. There are uncommon cases where fts_safe_changedir() may be called with a non-NULL name that is not "..". Do not block or worse if an attacker put (a (symlink to) a fifo or device where a directory used to be. MFC after: 1 week Modified: head/lib/libc/gen/fts.c Modified: head/lib/libc/gen/fts.c ============================================================================== --- head/lib/libc/gen/fts.c Sun Feb 10 22:06:06 2013 (r246640) +++ head/lib/libc/gen/fts.c Sun Feb 10 23:09:15 2013 (r246641) @@ -1119,7 +1119,8 @@ fts_safe_changedir(FTS *sp, FTSENT *p, i newfd = fd; if (ISSET(FTS_NOCHDIR)) return (0); - if (fd < 0 && (newfd = _open(path, O_RDONLY | O_CLOEXEC, 0)) < 0) + if (fd < 0 && (newfd = _open(path, O_RDONLY | O_DIRECTORY | + O_CLOEXEC, 0)) < 0) return (-1); if (_fstat(newfd, &sb)) { ret = -1;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201302102309.r1AN9FZ3047020>