aboutsummaryrefslogtreecommitdiff
path: root/src/rc/start-stop-daemon.c
diff options
context:
space:
mode:
authorWilliam Hubbs <w.d.hubbs@gmail.com>2018-06-19 17:46:12 -0500
committerWilliam Hubbs <w.d.hubbs@gmail.com>2018-06-19 17:46:12 -0500
commitf9d41243d8499c5d7027177d5aa716d5b5859cd6 (patch)
tree5d150d393ce37184ad8b0b42d0c0dde4aaf0a5e6 /src/rc/start-stop-daemon.c
parentbe7ad06d4a0efce2a1144b2cf6f0cc361f2a81e4 (diff)
start-stop-daemon: convert snprintf calls to xasprintf
Diffstat (limited to 'src/rc/start-stop-daemon.c')
-rw-r--r--src/rc/start-stop-daemon.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index a04a00ec..33f886c4 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -167,20 +167,20 @@ handle_signal(int sig)
{
int status;
int serrno = errno;
- char signame[10] = { '\0' };
+ char *signame = NULL;
switch (sig) {
case SIGINT:
- if (!signame[0])
- snprintf(signame, sizeof(signame), "SIGINT");
+ if (!signame)
+ xasprintf(&signame, "SIGINT");
/* FALLTHROUGH */
case SIGTERM:
- if (!signame[0])
- snprintf(signame, sizeof(signame), "SIGTERM");
+ if (!signame)
+ xasprintf(&signame, "SIGTERM");
/* FALLTHROUGH */
case SIGQUIT:
- if (!signame[0])
- snprintf(signame, sizeof(signame), "SIGQUIT");
+ if (!signame)
+ xasprintf(&signame, "SIGQUIT");
eerrorx("%s: caught %s, aborting", applet, signame);
/* NOTREACHED */
@@ -199,6 +199,9 @@ handle_signal(int sig)
eerror("%s: caught unknown signal %d", applet, sig);
}
+ /* free signame */
+ free(signame);
+
/* Restore errno */
errno = serrno;
}
@@ -207,7 +210,6 @@ static char *
expand_home(const char *home, const char *path)
{
char *opath, *ppath, *p, *nh;
- size_t len;
struct passwd *pw;
if (!path || *path != '~')
@@ -238,9 +240,7 @@ expand_home(const char *home, const char *path)
return xstrdup(home);
}
- len = strlen(ppath) + strlen(home) + 1;
- nh = xmalloc(len);
- snprintf(nh, len, "%s%s", home, ppath);
+ xasprintf(&nh, "%s%s", home, ppath);
free(opath);
return nh;
}