krb5 commit: Fix errno hygiene in kadmind write_pid_file
Greg Hudson
ghudson at MIT.EDU
Fri Mar 29 11:41:36 EDT 2013
https://github.com/krb5/krb5/commit/fb473d814d5b422c67f2e2e69764edee1fdd9783
commit fb473d814d5b422c67f2e2e69764edee1fdd9783
Author: Greg Hudson <ghudson at mit.edu>
Date: Fri Mar 29 02:22:12 2013 -0400
Fix errno hygiene in kadmind write_pid_file
fclose() might overwrite the errno value from fprintf, causing us to
return success when we shouldn't. Record the errno value at the time
of the fprintf failure.
src/kadmin/server/ovsec_kadmd.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/kadmin/server/ovsec_kadmd.c b/src/kadmin/server/ovsec_kadmd.c
index a1fee7e..dad7248 100644
--- a/src/kadmin/server/ovsec_kadmd.c
+++ b/src/kadmin/server/ovsec_kadmd.c
@@ -194,9 +194,9 @@ write_pid_file(const char *pid_file)
if (file == NULL)
return errno;
pid = (unsigned long) getpid();
- st1 = fprintf(file, "%ld\n", pid);
- st2 = fclose(file);
- return (st1 < 0 || st2 == EOF) ? errno : 0;
+ st1 = (fprintf(file, "%ld\n", pid) < 0) ? errno : 0;
+ st2 = (fclose(file) == EOF) ? errno : 0;
+ return st1 ? st1 : st2;
}
/* XXX yuck. the signal handlers need this */
More information about the cvs-krb5
mailing list