Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 7 Aug 2019 19:30:33 +0000 (UTC)
From:      Mariusz Zaborski <oshogbo@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r350695 - head/lib/libcasper/services/cap_fileargs
Message-ID:  <201908071930.x77JUXxh084437@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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]);
 	}
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201908071930.x77JUXxh084437>