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.
This commit is contained in:
keanehatescoding authored and Yves Rutschle committed 2026-05-08 22:42:13 +02:00
1 parent dc70cc0d3b
commit 6c0dc269c7
1 file changed
+3 -3
+3 -3
View File
@@ -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");