From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 2D413138334 for ; Tue, 19 Jun 2018 23:00:18 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 3DED4E090A; Tue, 19 Jun 2018 23:00:17 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 15BAAE090A for ; Tue, 19 Jun 2018 23:00:16 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 18302335C8E for ; Tue, 19 Jun 2018 23:00:06 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 852A92CB for ; Tue, 19 Jun 2018 23:00:04 +0000 (UTC) From: "William Hubbs" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "William Hubbs" Message-ID: <1529448372.f9d41243d8499c5d7027177d5aa716d5b5859cd6.williamh@OpenRC> Subject: [gentoo-commits] proj/openrc:master commit in: src/rc/ X-VCS-Repository: proj/openrc X-VCS-Files: src/rc/start-stop-daemon.c X-VCS-Directories: src/rc/ X-VCS-Committer: williamh X-VCS-Committer-Name: William Hubbs X-VCS-Revision: f9d41243d8499c5d7027177d5aa716d5b5859cd6 X-VCS-Branch: master Date: Tue, 19 Jun 2018 23:00:04 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: d900f441-6d59-47a1-8a2e-6592f07c178b X-Archives-Hash: 17554cc30e9da7814921a11194735729 commit: f9d41243d8499c5d7027177d5aa716d5b5859cd6 Author: William Hubbs gmail com> AuthorDate: Tue Jun 19 22:46:12 2018 +0000 Commit: William Hubbs gentoo org> CommitDate: Tue Jun 19 22:46:12 2018 +0000 URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=f9d41243 start-stop-daemon: convert snprintf calls to xasprintf src/rc/start-stop-daemon.c | 22 +++++++++++----------- 1 file 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; }