svn commit: r299508 - head/tests/sys/kern
Conrad E. Meyer
cem at FreeBSD.org
Thu May 12 03:44:31 UTC 2016
Author: cem
Date: Thu May 12 03:44:29 2016
New Revision: 299508
URL: https://svnweb.freebsd.org/changeset/base/299508
Log:
kern_descrip_test: Fix trivial buffer overrun with readlink(2)
Reported by: Coverity
CID: 1229965, 1229972
Sponsored by: EMC / Isilon Storage Division
Modified:
head/tests/sys/kern/kern_descrip_test.c
Modified: head/tests/sys/kern/kern_descrip_test.c
==============================================================================
--- head/tests/sys/kern/kern_descrip_test.c Thu May 12 03:37:17 2016 (r299507)
+++ head/tests/sys/kern/kern_descrip_test.c Thu May 12 03:44:29 2016 (r299508)
@@ -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,
More information about the svn-src-head
mailing list