From 296acffe45a74a8c9cca393494760169b5a4afd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 7 Dec 2018 16:12:19 +0100 Subject: [PATCH] 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. --- src/basic/path-util.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/basic/path-util.c b/src/basic/path-util.c index 995f39f16e..221517303e 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; }