systemd/backport-exec-invoke-correct-dont_close-size.patch
2024-12-11 11:55:52 +08:00

46 lines
1.4 KiB
Diff

From 57500859121e207b78f92452de80fb341f1776f2 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Tue, 23 Apr 2024 21:49:12 +0200
Subject: [PATCH] exec-invoke: correct dont_close[] size
THis needs 15 entries as far as I can count, not just 14.
Follow-up for: 5686391b006ee82d8a4559067ad9818e3e631247
Sniff.
(cherry picked from commit 07296542d636dcac43f6c9ee45a638fca8c5f3dd)
(cherry picked from commit 8f4dab049074d31c31af2bb9eb76f9f4f08e3711)
Conflict:in the current version, the length of the array is actually 13.
Reference:https://github.com/systemd/systemd-stable/commit/57500859121e207b78f92452de80fb341f1776f2
---
src/core/execute.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/core/execute.c b/src/core/execute.c
index f4700c1b0b..7d69572ce4 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -4402,7 +4402,7 @@ static int close_remaining_fds(
const int *fds, size_t n_fds) {
size_t n_dont_close = 0;
- int dont_close[n_fds + 12];
+ int dont_close[n_fds + 13];
assert(params);
@@ -4438,6 +4438,8 @@ static int close_remaining_fds(
if (user_lookup_fd >= 0)
dont_close[n_dont_close++] = user_lookup_fd;
+ assert(n_dont_close <= ELEMENTSOF(dont_close));
+
return close_all_fds(dont_close, n_dont_close);
}
--
2.33.0