diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-04-16 22:19:07 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-04-18 20:28:34 +0200 |
commit | 24be89ebd8e9fbf97cb60c304b615ab26869c204 (patch) | |
tree | bd11a80e427d171dc59233f5a0dc7146128baa5e /src/test | |
parent | chase: make chaseat() provides absolute path also when dir_fd points to the r... (diff) | |
download | systemd-24be89ebd8e9fbf97cb60c304b615ab26869c204.tar.xz systemd-24be89ebd8e9fbf97cb60c304b615ab26869c204.zip |
chase: make the result absolute when a symlink is absolute
As the path may be outside of the specified dir_fd.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test-chase.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/test/test-chase.c b/src/test/test-chase.c index 52ea21a54c..c5fc08ca25 100644 --- a/src/test/test-chase.c +++ b/src/test/test-chase.c @@ -457,7 +457,16 @@ TEST(chaseat) { fd = safe_close(fd); - /* If the file descriptor does not point to the root directory, the result will be relative. */ + /* If the file descriptor does not point to the root directory, the result will be relative + * unless the result is outside of the specified file descriptor. */ + + assert_se(chaseat(tfd, "abc", 0, &result, NULL) >= 0); + assert_se(streq(result, "/usr")); + result = mfree(result); + + assert_se(chaseat(tfd, "/abc", 0, &result, NULL) >= 0); + assert_se(streq(result, "/usr")); + result = mfree(result); assert_se(chaseat(tfd, "abc", CHASE_AT_RESOLVE_IN_ROOT, NULL, NULL) == -ENOENT); assert_se(chaseat(tfd, "/abc", CHASE_AT_RESOLVE_IN_ROOT, NULL, NULL) == -ENOENT); |