diff options
author | Ed Maste <emaste@FreeBSD.org> | 2019-10-02 21:01:23 +0000 |
---|---|---|
committer | Ed Maste <emaste@FreeBSD.org> | 2019-10-02 21:01:23 +0000 |
commit | f91dd6091b10668fd561fd77d12044a0dac1160d (patch) | |
tree | 558adbcc7fc26cc5fecce1f205924bceaa05eb7c /sys/kern/vfs_subr.c | |
parent | 31f1c8fc84c850d73e74781126e12efceb50032b (diff) | |
download | src-f91dd6091b10668fd561fd77d12044a0dac1160d.tar.gz src-f91dd6091b10668fd561fd77d12044a0dac1160d.zip |
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
Notes
Notes:
svn path=/head/; revision=353021
Diffstat (limited to 'sys/kern/vfs_subr.c')
-rw-r--r-- | sys/kern/vfs_subr.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 7d8ea63c7a6f..8d2579f63e54 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -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; |