aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNRK <nrk@disroot.org>2023-01-31 06:24:01 +0600
committerMike Frysinger <vapier@gmail.com>2023-01-30 22:54:20 -0500
commit5858f980c87ce028612903bee20dde1bfc6e0125 (patch)
tree7d35f1ec4276dc7aef79a0b67d291f8e1081cbdc /src
parentdb96295e000994963a5e0c4b4d121c3ad0353670 (diff)
openrc-run: avoid malloc inside sig-handler
same rational as 459783bb Bug: https://github.com/OpenRC/openrc/issues/589
Diffstat (limited to 'src')
-rw-r--r--src/openrc-run/openrc-run.c9
1 files 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 */