From 6c0dc269c7c9bf5be51e9df1beed34e4f216cd4a Mon Sep 17 00:00:00 2001 From: keanehatescoding Date: Tue, 28 Apr 2026 02:57:30 +0300 Subject: [PATCH] fix: close err_log after writing success message in main() err_log was fclose()'d before the "Successfully generated all targets" fprintf(), resulting in a write-after-close that corrupted glibc's internal stdio buffers and triggered an abort() via SIGABRT on every systemd-invoked run regardless of whether /etc/sslh/ exists. Fix by moving the success fprintf() above the fclose() call. --- systemd-sslh-generator.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/systemd-sslh-generator.c b/systemd-sslh-generator.c index 1082a43..50ba555 100644 --- a/systemd-sslh-generator.c +++ b/systemd-sslh-generator.c @@ -307,12 +307,12 @@ int main(int argc, char *argv[]) { err_log = stderr; } const int r = gen_sslh_config(systemd_invoked ? argv[1] : ""); - if (systemd_invoked) { - fclose(err_log); - } if (!r) { fprintf(err_log, "systemd-sslh-generator: Successfully generated all targets.\n"); } + if (systemd_invoked) { + fclose(err_log); + } return r < 0 ? -1 : 0; } else { printf("This program takes three or no arguments.\n");