From 5858f980c87ce028612903bee20dde1bfc6e0125 Mon Sep 17 00:00:00 2001 From: NRK Date: Tue, 31 Jan 2023 06:24:01 +0600 Subject: openrc-run: avoid malloc inside sig-handler same rational as 459783bb Bug: https://github.com/OpenRC/openrc/issues/589 --- src/openrc-run/openrc-run.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/openrc-run/openrc-run.c b/src/openrc-run/openrc-run.c index 0ede04a6..2b1d3746 100644 --- a/src/openrc-run/openrc-run.c +++ b/src/openrc-run/openrc-run.c @@ -108,7 +108,7 @@ static void handle_signal(int sig) { int serrno = errno; - char *signame = NULL; + const char *signame = NULL; struct winsize ws; switch (sig) { @@ -134,20 +134,19 @@ handle_signal(int sig) case SIGINT: if (!signame) - xasprintf(&signame, "SIGINT"); + signame = "SIGINT"; /* FALLTHROUGH */ case SIGTERM: if (!signame) - xasprintf(&signame, "SIGTERM"); + signame = "SIGTERM"; /* FALLTHROUGH */ case SIGQUIT: if (!signame) - xasprintf(&signame, "SIGQUIT"); + signame = "SIGQUIT"; /* Send the signal to our children too */ if (service_pid > 0) kill(service_pid, sig); eerror("%s: caught %s, aborting", applet, signame); - free(signame); exit(EXIT_FAILURE); /* NOTREACHED */ -- cgit v1.2.3