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 0CC441382C5 for ; Tue, 20 Feb 2018 22:36:57 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 2D292E087E; Tue, 20 Feb 2018 22:36:56 +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 0BBF2E087E for ; Tue, 20 Feb 2018 22:36:55 +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 242F4335C34 for ; Tue, 20 Feb 2018 22:36:55 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id D1F561FE for ; Tue, 20 Feb 2018 22:36:48 +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: <1519158149.8e02406d8fbf92167c30431987d5de8de72cd7df.williamh@OpenRC> Subject: [gentoo-commits] proj/openrc:master commit in: src/rc/ X-VCS-Repository: proj/openrc X-VCS-Files: src/rc/rc-misc.c X-VCS-Directories: src/rc/ X-VCS-Committer: williamh X-VCS-Committer-Name: William Hubbs X-VCS-Revision: 8e02406d8fbf92167c30431987d5de8de72cd7df X-VCS-Branch: master Date: Tue, 20 Feb 2018 22:36:48 +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: cf94c4fd-52b5-42ed-8675-a0237aa759ad X-Archives-Hash: 46ec288796f0329351a940b200ac3f59 commit: 8e02406d8fbf92167c30431987d5de8de72cd7df Author: William Hubbs gmail com> AuthorDate: Tue Feb 20 20:22:29 2018 +0000 Commit: William Hubbs gentoo org> CommitDate: Tue Feb 20 20:22:29 2018 +0000 URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=8e02406d rc-misc.c: remove references to PATH_MAX src/rc/rc-misc.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/rc/rc-misc.c b/src/rc/rc-misc.c index 21c06fc5..2c9903c3 100644 --- a/src/rc/rc-misc.c +++ b/src/rc/rc-misc.c @@ -131,7 +131,8 @@ env_config(void) char *npp; char *tok; const char *sys = rc_sys(); - char buffer[PATH_MAX]; + char *buffer = NULL; + size_t size = 0; /* Ensure our PATH is prefixed with the system locations first for a little extra security */ @@ -170,8 +171,7 @@ env_config(void) free(e); if ((fp = fopen(RC_KRUNLEVEL, "r"))) { - memset(buffer, 0, sizeof (buffer)); - if (fgets(buffer, sizeof (buffer), fp)) { + if (getline(&buffer, &size, fp) != -1) { l = strlen (buffer) - 1; if (buffer[l] == '\n') buffer[l] = 0; @@ -181,6 +181,7 @@ env_config(void) } else setenv("RC_DEFAULTLEVEL", RC_LEVEL_DEFAULT, 1); + free(buffer); if (sys) setenv("RC_SYS", sys, 1); @@ -232,11 +233,12 @@ signal_setup_restart(int sig, void (*handler)(int)) int svc_lock(const char *applet) { - char file[PATH_MAX]; + char *file = NULL; int fd; - snprintf(file, sizeof(file), RC_SVCDIR "/exclusive/%s", applet); + xasprintf(&file, RC_SVCDIR "/exclusive/%s", applet); fd = open(file, O_WRONLY | O_CREAT | O_NONBLOCK, 0664); + free(file); if (fd == -1) return -1; if (flock(fd, LOCK_EX | LOCK_NB) == -1) { @@ -250,11 +252,12 @@ svc_lock(const char *applet) int svc_unlock(const char *applet, int fd) { - char file[PATH_MAX]; + char *file = NULL; - snprintf(file, sizeof(file), RC_SVCDIR "/exclusive/%s", applet); + xasprintf(&file, RC_SVCDIR "/exclusive/%s", applet); close(fd); unlink(file); + free(file); return -1; } @@ -358,7 +361,7 @@ RC_DEPTREE * _rc_deptree_load(int force, int *regen) int serrno = errno; int merrno; time_t t; - char file[PATH_MAX]; + char *file = NULL; struct stat st; struct utimbuf ut; FILE *fp;