0daf48d9aa
Resolves: #2047682,#2068043,#2068131,#2073003,#2073994,#2082131,#2083493,#2087652,#2100340
37 lines
1.2 KiB
Diff
37 lines
1.2 KiB
Diff
From 936e8cd5aff044832c98e5a6a97c9f057f44b476 Mon Sep 17 00:00:00 2001
|
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
Date: Tue, 22 Feb 2022 21:44:58 +0900
|
|
Subject: [PATCH] test: fix file descriptor leak in test-tmpfiles.c
|
|
|
|
Also fixes a typo in assertion.
|
|
|
|
Fixes an issure reported in #22576.
|
|
|
|
(cherry picked from commit 1da5325d19dee654326e5fa2f61262e5e0a40fff)
|
|
Related: #2087652
|
|
---
|
|
src/test/test-tmpfiles.c | 3 ++-
|
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/test/test-tmpfiles.c b/src/test/test-tmpfiles.c
|
|
index 99243eb77a..f26701767f 100644
|
|
--- a/src/test/test-tmpfiles.c
|
|
+++ b/src/test/test-tmpfiles.c
|
|
@@ -35,7 +35,7 @@ TEST(tmpfiles) {
|
|
assert_se(endswith(ans, " (deleted)"));
|
|
|
|
fd2 = mkostemp_safe(pattern);
|
|
- assert_se(fd >= 0);
|
|
+ assert_se(fd2 >= 0);
|
|
assert_se(unlink(pattern) == 0);
|
|
|
|
assert_se(asprintf(&cmd2, "ls -l /proc/"PID_FMT"/fd/%d", getpid_cached(), fd2) > 0);
|
|
@@ -47,6 +47,7 @@ TEST(tmpfiles) {
|
|
pattern = strjoina(p, "/tmpfiles-test");
|
|
assert_se(tempfn_random(pattern, NULL, &d) >= 0);
|
|
|
|
+ fd = safe_close(fd);
|
|
fd = open_tmpfile_linkable(d, O_RDWR|O_CLOEXEC, &tmp);
|
|
assert_se(fd >= 0);
|
|
assert_se(write(fd, "foobar\n", 7) == 7);
|