1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-25 01:34:28 +03:00

shared/install: fix set-default with empty root (#4118)

https://bugzilla.redhat.com/show_bug.cgi?id=1374371

When root was empty or equal to "/", chroot_symlinks_same was called with
root==NULL, and strjoina returned "", so the code thought both paths are equal
even if they were not. Fix that by always providing a non-null first argument
to strjoina.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2016-09-10 12:07:51 +01:00 committed by Martin Pitt
parent 4245eb5072
commit ae9efab711

View File

@ -403,6 +403,9 @@ static bool chroot_symlinks_same(const char *root, const char *wd, const char *a
/* This will give incorrect results if the paths are relative and go outside
* of the chroot. False negatives are possible. */
if (!root)
root = "/";
a = strjoina(path_is_absolute(a) ? root : wd, "/", a);
b = strjoina(path_is_absolute(b) ? root : wd, "/", b);
return path_equal_or_files_same(a, b);