diff options
author | NRK <nrk@disroot.org> | 2023-01-31 06:31:31 +0600 |
---|---|---|
committer | Mike Frysinger <vapier@gmail.com> | 2023-01-30 22:54:20 -0500 |
commit | ae5e38dce5bd7b30adb3131e7e76fab34a6f5c73 (patch) | |
tree | 0109b894dfa5cfa04df2c8bfa2474c867cb89511 | |
parent | 5858f980c87ce028612903bee20dde1bfc6e0125 (diff) |
start-stop-daemon: avoid malloc inside sig-handler
same rational as 459783bb
Bug: https://github.com/OpenRC/openrc/issues/589
-rw-r--r-- | src/start-stop-daemon/start-stop-daemon.c | 11 |
1 files changed, 4 insertions, 7 deletions
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; } |