start-stop-daemon: avoid malloc inside sig-handler
same rational as 459783bb
Bug: https://github.com/OpenRC/openrc/issues/589
This commit is contained in:
parent
5858f980c8
commit
ae5e38dce5
@ -204,20 +204,20 @@ handle_signal(int sig)
|
|||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
int serrno = errno;
|
int serrno = errno;
|
||||||
char *signame = NULL;
|
const char *signame = NULL;
|
||||||
|
|
||||||
switch (sig) {
|
switch (sig) {
|
||||||
case SIGINT:
|
case SIGINT:
|
||||||
if (!signame)
|
if (!signame)
|
||||||
xasprintf(&signame, "SIGINT");
|
signame = "SIGINT";
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
if (!signame)
|
if (!signame)
|
||||||
xasprintf(&signame, "SIGTERM");
|
signame = "SIGTERM";
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case SIGQUIT:
|
case SIGQUIT:
|
||||||
if (!signame)
|
if (!signame)
|
||||||
xasprintf(&signame, "SIGQUIT");
|
signame = "SIGQUIT";
|
||||||
eerrorx("%s: caught %s, aborting", applet, signame);
|
eerrorx("%s: caught %s, aborting", applet, signame);
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
|
|
||||||
@ -236,9 +236,6 @@ handle_signal(int sig)
|
|||||||
eerror("%s: caught unknown signal %d", applet, sig);
|
eerror("%s: caught unknown signal %d", applet, sig);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free signame */
|
|
||||||
free(signame);
|
|
||||||
|
|
||||||
/* Restore errno */
|
/* Restore errno */
|
||||||
errno = serrno;
|
errno = serrno;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user