summaryrefslogtreecommitdiffstats
path: root/src/basic/chase.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:42 +0000
commit78e9bb837c258ac0ec7712b3d612cc2f407e731e (patch)
treef515d16b6efd858a9aeb5b0ef5d6f90bf288283d /src/basic/chase.c
parentAdding debian version 255.5-1. (diff)
downloadsystemd-78e9bb837c258ac0ec7712b3d612cc2f407e731e.tar.xz
systemd-78e9bb837c258ac0ec7712b3d612cc2f407e731e.zip
Merging upstream version 256.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/basic/chase.c')
-rw-r--r--src/basic/chase.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/basic/chase.c b/src/basic/chase.c
index 9f5477e..4576e4b 100644
--- a/src/basic/chase.c
+++ b/src/basic/chase.c
@@ -641,8 +641,8 @@ int chase(const char *path, const char *root, ChaseFlags flags, char **ret_path,
* absolute, hence it is not necessary to prefix with the root. When "root" points to
* a non-root directory, the result path is always normalized and relative, hence
* we can simply call path_join() and not necessary to call path_simplify().
- * Note that the result of chaseat() may start with "." (more specifically, it may be
- * "." or "./"), and we need to drop "." in that case. */
+ * As a special case, chaseat() may return "." or "./", which are normalized too,
+ * but we need to drop "." before merging with root. */
if (empty_or_root(root))
assert(path_is_absolute(p));
@@ -651,7 +651,7 @@ int chase(const char *path, const char *root, ChaseFlags flags, char **ret_path,
assert(!path_is_absolute(p));
- q = path_join(root, p + (*p == '.'));
+ q = path_join(root, p + STR_IN_SET(p, ".", "./"));
if (!q)
return -ENOMEM;
@@ -741,12 +741,7 @@ int chase_extract_filename(const char *path, const char *root, char **ret) {
return r;
}
- char *fname = strdup(".");
- if (!fname)
- return -ENOMEM;
-
- *ret = fname;
- return 0;
+ return strdup_to(ret, ".");
}
int chase_and_open(const char *path, const char *root, ChaseFlags chase_flags, int open_flags, char **ret_path) {