Skip to content

Commit

Permalink
util: be a bit safer in path_is_safe()
Browse files Browse the repository at this point in the history
We should be more strict when verifying paths with path_is_safe() for
potentially dangerous constructs, and that includes lengths of
PATH_MAX-1 and larger. Be more accurate here.
  • Loading branch information
poettering committed May 5, 2015
1 parent e66e5b6 commit 6442185
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/shared/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -3917,7 +3917,7 @@ bool path_is_safe(const char *p) {
if (streq(p, "..") || startswith(p, "../") || endswith(p, "/..") || strstr(p, "/../"))
return false;

if (strlen(p) > PATH_MAX)
if (strlen(p)+1 > PATH_MAX)
return false;

/* The following two checks are not really dangerous, but hey, they still are confusing */
Expand Down

0 comments on commit 6442185

Please sign in to comment.