From owner-svn-src-all@FreeBSD.ORG Sun Feb 28 13:31:29 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C2FAD1065672; Sun, 28 Feb 2010 13:31:29 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B31C88FC18; Sun, 28 Feb 2010 13:31:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1SDVTn8091176; Sun, 28 Feb 2010 13:31:29 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1SDVTvd091174; Sun, 28 Feb 2010 13:31:29 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201002281331.o1SDVTvd091174@svn.freebsd.org> From: Jaakko Heinonen Date: Sun, 28 Feb 2010 13:31:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204447 - head/lib/libc/stdio X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Feb 2010 13:31:29 -0000 Author: jh Date: Sun Feb 28 13:31:29 2010 New Revision: 204447 URL: http://svn.freebsd.org/changeset/base/204447 Log: In _gettemp(), check that the length of the path doesn't exceed MAXPATHLEN. Otherwise the path name (or part of it) may not fit to carrybuf causing a buffer overflow. PR: bin/140228 Suggested by: jilles Modified: head/lib/libc/stdio/mktemp.c Modified: head/lib/libc/stdio/mktemp.c ============================================================================== --- head/lib/libc/stdio/mktemp.c Sun Feb 28 11:27:03 2010 (r204446) +++ head/lib/libc/stdio/mktemp.c Sun Feb 28 13:31:29 2010 (r204447) @@ -116,6 +116,10 @@ _gettemp(path, doopen, domkdir, slen) for (trv = path; *trv != '\0'; ++trv) ; + if (trv - path >= MAXPATHLEN) { + errno = ENAMETOOLONG; + return (0); + } trv -= slen; suffp = trv; --trv;