From dc5de3fc033c453012e59890de3548f10d21fa78 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 13 Aug 2026 05:10:16 +0900 Subject: [PATCH] json-stream: refuse to attach already attached fds json_stream_attach_fds() closes already attached fds. Hence, the new fds must be different from the already attached ones. --- src/libsystemd/sd-json/json-stream.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libsystemd/sd-json/json-stream.c b/src/libsystemd/sd-json/json-stream.c index ed4b6ca5b1..66d9fa9f61 100644 --- a/src/libsystemd/sd-json/json-stream.c +++ b/src/libsystemd/sd-json/json-stream.c @@ -220,6 +220,12 @@ int json_stream_attach_fds(JsonStream *s, int input_fd, int output_fd) { struct stat st; assert(s); + assert(input_fd >= 0); + assert(input_fd != s->input_fd); + assert(input_fd != s->output_fd); + assert(output_fd >= 0); + assert(output_fd != s->input_fd); + assert(output_fd != s->output_fd); /* NB: input_fd and output_fd are donated to the JsonStream instance! */