]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
execute: Pass AT_FDCWD instead of -1
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 13 Dec 2022 10:50:01 +0000 (10:50 +0000)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 13 Dec 2022 13:00:34 +0000 (22:00 +0900)
Let's enforce that callers pass AT_FDCWD as read_dfd to load_credential()
to avoid an assert() in read_full_file_full() if read_dfd is -1.

src/core/execute.c

index 8e70ecab8219947a0d81b738e10fab44e4c90f1c..7963582ea2f24095ee545249fa39965ef528fe3e 100644 (file)
@@ -2663,6 +2663,7 @@ static int load_credential(
         assert(id);
         assert(path);
         assert(unit);
+        assert(read_dfd >= 0 || read_dfd == AT_FDCWD);
         assert(write_dfd >= 0);
         assert(left);
 
@@ -2889,7 +2890,7 @@ static int acquire_credentials(
                                         lc->path,
                                         lc->encrypted,
                                         unit,
-                                        -1,
+                                        AT_FDCWD,
                                         dfd,
                                         uid,
                                         ownership_ok,