if (hashmap_contains(u->requires_mounts_for, path)) /* Exit quickly if the path is already covered. */
return 0;
- _cleanup_free_ char *p = strdup(path);
- if (!p)
- return -ENOMEM;
-
/* Use the canonical form of the path as the stored key. We call path_is_normalized()
* only after simplification, since path_is_normalized() rejects paths with '.'.
* path_is_normalized() also verifies that the path fits in PATH_MAX. */
- path = path_simplify(p);
+ _cleanup_free_ char *p = NULL;
+ r = path_simplify_alloc(path, &p);
+ if (r < 0)
+ return r;
+ path = p;
if (!path_is_normalized(path))
return -EPERM;
if (r < 0)
return r;
- n = strdup(p);
- if (!n)
- return -ENOMEM;
-
- path_simplify(n);
+ r = path_simplify_alloc(p, &n);
+ if (r < 0)
+ return r;
r = set_consume(*remove_symlinks_to, n);
if (r == -EEXIST)
_cleanup_free_ char *c = NULL;
const char *p;
bool exec;
+ int r;
assert_return(ret, -EINVAL);
assert_return(url, -EINVAL);
if (!path_is_absolute(p))
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "Specified path not absolute, refusing.");
- c = strdup(p);
- if (!c)
- return log_oom_debug();
-
- path_simplify(c);
+ r = path_simplify_alloc(p, &c);
+ if (r < 0)
+ return r;
if (!path_is_normalized(c))
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "Specified path is not normalized, refusing.");