From ae5e38dce5bd7b30adb3131e7e76fab34a6f5c73 Mon Sep 17 00:00:00 2001 From: NRK Date: Tue, 31 Jan 2023 06:31:31 +0600 Subject: start-stop-daemon: avoid malloc inside sig-handler same rational as 459783bb Bug: https://github.com/OpenRC/openrc/issues/589 --- src/start-stop-daemon/start-stop-daemon.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/start-stop-daemon/start-stop-daemon.c b/src/start-stop-daemon/start-stop-daemon.c index 07fab393..c277345d 100644 --- a/src/start-stop-daemon/start-stop-daemon.c +++ b/src/start-stop-daemon/start-stop-daemon.c @@ -204,20 +204,20 @@ handle_signal(int sig) { int status; int serrno = errno; - char *signame = NULL; + const char *signame = NULL; switch (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"; eerrorx("%s: caught %s, aborting", applet, signame); /* NOTREACHED */ @@ -236,9 +236,6 @@ handle_signal(int sig) eerror("%s: caught unknown signal %d", applet, sig); } - /* free signame */ - free(signame); - /* Restore errno */ errno = serrno; } -- cgit v1.2.3