summaryrefslogtreecommitdiffstats
path: root/src/kadmin
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2013-03-25 17:38:41 -0400
committerGreg Hudson <ghudson@mit.edu>2013-03-26 13:01:29 -0400
commit47ec1ab146334f94b97e6572904a14ad67ee2524 (patch)
treea338690a8f7f741a1f9d52f9898fc9758c7e5e0b /src/kadmin
parentfb92e73d12081d36b0497e55489293d296eb416d (diff)
downloadkrb5-47ec1ab146334f94b97e6572904a14ad67ee2524.tar.gz
krb5-47ec1ab146334f94b97e6572904a14ad67ee2524.tar.xz
krb5-47ec1ab146334f94b97e6572904a14ad67ee2524.zip
Fix a trivial file leak writing kadmind pid file
If we fail to write the pid to the pid file, we should still close the file before returning from write_pid_file(). The consequences of this bug are trivial because kadmin is just going to exit regardless. Reported by Will Fiveash <will.fiveash@oracle.com>.
Diffstat (limited to 'src/kadmin')
-rw-r--r--src/kadmin/server/ovsec_kadmd.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/kadmin/server/ovsec_kadmd.c b/src/kadmin/server/ovsec_kadmd.c
index 60a2afbb9c..a1fee7e3aa 100644
--- a/src/kadmin/server/ovsec_kadmd.c
+++ b/src/kadmin/server/ovsec_kadmd.c
@@ -188,14 +188,15 @@ write_pid_file(const char *pid_file)
{
FILE *file;
unsigned long pid;
+ int st1, st2;
file = fopen(pid_file, "w");
if (file == NULL)
return errno;
pid = (unsigned long) getpid();
- if (fprintf(file, "%ld\n", pid) < 0 || fclose(file) == EOF)
- return errno;
- return 0;
+ st1 = fprintf(file, "%ld\n", pid);
+ st2 = fclose(file);
+ return (st1 < 0 || st2 == EOF) ? errno : 0;
}
/* XXX yuck. the signal handlers need this */