cap_filergs: limit size of the file name

The limit of the name in fileargs is twice the size of the MAXPATH.
The nvlist will not add an element with the longer name.
We can detect at this point that the path is too big, and simple return
the same error as open(2) would.

PR:		239700
Reported by:	markj
Tested by:	markj
MFC after:	2 weeks
This commit is contained in:
Mariusz Zaborski 2019-08-07 19:30:33 +00:00
parent ac03832ef3
commit 9509775394

View File

@ -185,6 +185,11 @@ fileargs_create_limit(int argc, const char * const *argv, int flags,
nvlist_add_number(limits, "mode", (uint64_t)mode);
for (i = 0; i < argc; i++) {
if (strlen(argv[i]) >= MAXPATHLEN) {
nvlist_destroy(limits);
errno = ENAMETOOLONG;
return (NULL);
}
nvlist_add_null(limits, argv[i]);
}