From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-763995-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	by finch.gentoo.org (Postfix) with ESMTP id C91F2138A1A
	for <garchives@archives.gentoo.org>; Mon, 12 Jan 2015 16:44:11 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id C45D1E085C;
	Mon, 12 Jan 2015 16:44:08 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 6DE1EE085C
	for <gentoo-commits@lists.gentoo.org>; Mon, 12 Jan 2015 16:44:08 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 18BA53406B3
	for <gentoo-commits@lists.gentoo.org>; Mon, 12 Jan 2015 16:44:07 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id B9B63F6CF
	for <gentoo-commits@lists.gentoo.org>; Mon, 12 Jan 2015 16:44:05 +0000 (UTC)
From: "William Hubbs" <williamh@gentoo.org>
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" <williamh@gentoo.org>
Message-ID: <1421080236.74478830a8d035c078e986b57efd40a5c48bc896.williamh@OpenRC>
Subject: [gentoo-commits] proj/openrc:master commit in: src/librc/
X-VCS-Repository: proj/openrc
X-VCS-Files: src/librc/librc-daemon.c
X-VCS-Directories: src/librc/
X-VCS-Committer: williamh
X-VCS-Committer-Name: William Hubbs
X-VCS-Revision: 74478830a8d035c078e986b57efd40a5c48bc896
X-VCS-Branch: master
Date: Mon, 12 Jan 2015 16:44:05 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Archives-Salt: 3d5a2635-8322-4cf2-b140-5f2f9adb3ebb
X-Archives-Hash: ade028a57c3e69874967b3dd1cb7116a

commit:     74478830a8d035c078e986b57efd40a5c48bc896
Author:     Doug Freed <dwfreed <AT> mtu <DOT> edu>
AuthorDate: Mon Jan 12 15:10:29 2015 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Jan 12 16:30:36 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=74478830

fix double free of pidfile

This fixes a double free of the pidfile variable. For discussion of this
issue, see the bug.

X-Gentoo-Bug: 531600
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=531600

---
 src/librc/librc-daemon.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/librc/librc-daemon.c b/src/librc/librc-daemon.c
index 02aff5a..76fdd7b 100644
--- a/src/librc/librc-daemon.c
+++ b/src/librc/librc-daemon.c
@@ -560,22 +560,20 @@ rc_service_daemons_crashed(const char *service)
 			spidfile = xmalloc(strlen(ch_root) + strlen(pidfile) + 1);
 			strcpy(spidfile, ch_root);
 			strcat(spidfile, pidfile);
+			free(pidfile);
+			pidfile = spidfile;
 		}
 
 		pid = 0;
-		if (spidfile) {
+		if (pidfile) {
 			retval = true;
-			if ((fp = fopen(spidfile, "r"))) {
+			if ((fp = fopen(pidfile, "r"))) {
 				if (fscanf(fp, "%d", &pid) == 1)
 					retval = false;
 				fclose(fp);
 			}
-			free(spidfile);
-			spidfile = NULL;
-			if (ch_root) {
-				free(pidfile);
-				pidfile = NULL;
-			}
+			free(pidfile);
+			pidfile = NULL;
 
 			/* We have the pid, so no need to match
 			   on exec or name */