Author: emaste
Date: Wed Oct  9 14:35:09 2019
New Revision: 353347
URL: https://svnweb.freebsd.org/changeset/base/353347

Log:
  MFC r353021: 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.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/12/sys/kern/vfs_subr.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/kern/vfs_subr.c
==============================================================================
--- stable/12/sys/kern/vfs_subr.c       Wed Oct  9 14:09:57 2019        
(r353346)
+++ stable/12/sys/kern/vfs_subr.c       Wed Oct  9 14:35:09 2019        
(r353347)
@@ -352,10 +352,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;
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to