Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 2 Oct 2019 21:01:24 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r353021 - head/sys/kern
Message-ID:  <201910022101.x92L1OSM020820@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Wed Oct  2 21:01:23 2019
New Revision: 353021
URL: https://svnweb.freebsd.org/changeset/base/353021

Log:
  simplify path handling in sysctl_try_reclaim_vnode
  
  MAXPATHLEN / PATH_MAX includes space for the terminating NUL, and namei
  verifies the presence of the NUL.  Thus there is no need to increase the
  buffer size here.
  
  The sysctl passes the string excluding the NUL, so req->newlen equal to
  PATH_MAX is too long.
  
  Reviewed by:	kib
  MFC after:	1 week
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D21876

Modified:
  head/sys/kern/vfs_subr.c

Modified: head/sys/kern/vfs_subr.c
==============================================================================
--- head/sys/kern/vfs_subr.c	Wed Oct  2 19:13:35 2019	(r353020)
+++ head/sys/kern/vfs_subr.c	Wed Oct  2 21:01:23 2019	(r353021)
@@ -351,10 +351,10 @@ sysctl_try_reclaim_vnode(SYSCTL_HANDLER_ARGS)
 
 	if (req->newptr == NULL)
 		return (EINVAL);
-	if (req->newlen > PATH_MAX)
+	if (req->newlen >= PATH_MAX)
 		return (E2BIG);
 
-	buf = malloc(PATH_MAX + 1, M_TEMP, M_WAITOK);
+	buf = malloc(PATH_MAX, M_TEMP, M_WAITOK);
 	error = SYSCTL_IN(req, buf, req->newlen);
 	if (error != 0)
 		goto out;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201910022101.x92L1OSM020820>