Date: Sun, 28 Feb 2010 13:31:29 +0000 (UTC) From: Jaakko Heinonen <jh@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r204447 - head/lib/libc/stdio Message-ID: <201002281331.o1SDVTvd091174@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201002281331.o1SDVTvd091174>