svn commit: r350695 - head/lib/libcasper/services/cap_fileargs

Mariusz Zaborski oshogbo at FreeBSD.org
Wed Aug 7 19:30:33 UTC 2019


Author: oshogbo
Date: Wed Aug  7 19:30:33 2019
New Revision: 350695
URL: https://svnweb.freebsd.org/changeset/base/350695

Log:
  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

Modified:
  head/lib/libcasper/services/cap_fileargs/cap_fileargs.c

Modified: head/lib/libcasper/services/cap_fileargs/cap_fileargs.c
==============================================================================
--- head/lib/libcasper/services/cap_fileargs/cap_fileargs.c	Wed Aug  7 19:28:35 2019	(r350694)
+++ head/lib/libcasper/services/cap_fileargs/cap_fileargs.c	Wed Aug  7 19:30:33 2019	(r350695)
@@ -185,6 +185,11 @@ fileargs_create_limit(int argc, const char * const *ar
 		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]);
 	}
 


More information about the svn-src-head mailing list