From: Zbigniew Jędrzejewski-Szmek Date: Fri, 7 Dec 2018 15:12:19 +0000 (+0100) Subject: When parsing paths, reject anything above PATH_MAX X-Git-Tag: v240~97^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=296acffe45a74a8c9cca393494760169b5a4afd3;p=thirdparty%2Fsystemd.git When parsing paths, reject anything above PATH_MAX The check for length is done after path_simplify(), to be nice to paths which are constructed using specifiers, and have duplicate slashes and stuff. --- diff --git a/src/basic/path-util.c b/src/basic/path-util.c index 995f39f16ef..221517303ec 100644 --- a/src/basic/path-util.c +++ b/src/basic/path-util.c @@ -1139,5 +1139,12 @@ int path_simplify_and_warn( return -EINVAL; } + if (!path_is_valid(path)) { + log_syntax(unit, LOG_ERR, filename, line, 0, + "%s= path has invalid length (%zu bytes)%s.", + lvalue, strlen(path), fatal ? "" : ", ignoring"); + return -EINVAL; + } + return 0; }