Be more careful when doing calculation with request from userland.

MFC after:	2 weeks
This commit is contained in:
delphij 2017-11-13 07:47:43 +00:00
parent 60dfbe416a
commit 62fdd4ef88

View File

@ -1956,7 +1956,7 @@ sysctl_kern_proc_args(SYSCTL_HANDLER_ARGS)
if (error != 0 || req->newptr == NULL)
return (error);
if (req->newlen + sizeof(struct pargs) > ps_arg_cache_limit)
if (req->newlen > ps_arg_cache_limit - sizeof(struct pargs))
return (ENOMEM);
newpa = pargs_alloc(req->newlen);
error = SYSCTL_IN(req, newpa->ar_args, req->newlen);