diff options
| author | Doug Freed <dwfreed@mtu.edu> | 2015-01-12 09:10:29 -0600 | 
|---|---|---|
| committer | William Hubbs <w.d.hubbs@gmail.com> | 2015-01-12 10:30:36 -0600 | 
| commit | 74478830a8d035c078e986b57efd40a5c48bc896 (patch) | |
| tree | 0e2224a514c29af4e11de6e4461c6d11481fb188 /src/librc | |
| parent | 6a9679377f4de257f02de1d16a513df14b4c25ba (diff) | |
| download | openrc-74478830a8d035c078e986b57efd40a5c48bc896.tar.xz | |
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
Diffstat (limited to 'src/librc')
| -rw-r--r-- | src/librc/librc-daemon.c | 14 | 
1 files changed, 6 insertions, 8 deletions
| diff --git a/src/librc/librc-daemon.c b/src/librc/librc-daemon.c index 02aff5a9..76fdd7b1 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 */ | 
