Date: Fri, 10 Jun 2016 18:07:35 +0000 (UTC) From: Garrett Cooper <ngie@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301805 - stable/10/tests/sys/kern Message-ID: <201606101807.u5AI7ZXu022315@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ngie Date: Fri Jun 10 18:07:35 2016 New Revision: 301805 URL: https://svnweb.freebsd.org/changeset/base/301805 Log: MFC r299508: r299508 (by cem): kern_descrip_test: Fix trivial buffer overrun with readlink(2) CID: 1229965, 1229972 Modified: stable/10/tests/sys/kern/kern_descrip_test.c Directory Properties: stable/10/ (props changed) Modified: stable/10/tests/sys/kern/kern_descrip_test.c ============================================================================== --- stable/10/tests/sys/kern/kern_descrip_test.c Fri Jun 10 18:04:54 2016 (r301804) +++ stable/10/tests/sys/kern/kern_descrip_test.c Fri Jun 10 18:07:35 2016 (r301805) @@ -27,6 +27,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <sys/param.h> #include <errno.h> #include <fcntl.h> #include <signal.h> @@ -170,7 +171,7 @@ ATF_TC_CLEANUP(kern_maxfiles__increase, char buf[80]; if ((n = readlink(VALUE, buf, sizeof(buf))) > 0) { - buf[n] = '\0'; + buf[MIN((size_t)n, sizeof(buf) - 1)] = '\0'; if (sscanf(buf, "%d", &oldmaxfiles) == 1) { oldlen = sizeof(oldmaxfiles); (void) sysctlbyname("kern.maxfiles", NULL, 0,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201606101807.u5AI7ZXu022315>