summaryrefslogtreecommitdiffstats
path: root/src/lib/kadm5/logger.c
diff options
context:
space:
mode:
authorEzra Peisach <epeisach@mit.edu>2001-06-04 15:28:21 +0000
committerEzra Peisach <epeisach@mit.edu>2001-06-04 15:28:21 +0000
commit5b7b7f4f01c2a90ece0080cde9a3dde1238f3788 (patch)
tree7f6af1455b1c4957e099657ba7644874415e6a55 /src/lib/kadm5/logger.c
parent86b9cba23d0f7ea4c4add8b2474a4fbeb067a82f (diff)
downloadkrb5-5b7b7f4f01c2a90ece0080cde9a3dde1238f3788.tar.gz
krb5-5b7b7f4f01c2a90ece0080cde9a3dde1238f3788.tar.xz
krb5-5b7b7f4f01c2a90ece0080cde9a3dde1238f3788.zip
* logger.c (krb5_klog_init): Cleanup assignments in
conditionals. Ensure that if hostname is MAXHOSTNAMELEN, buffer is \0 terminated. * str_conv.c (krb5_string_to_keysalts, krb5_keysalt_iterate): Clean up assignments in conditionals. * admin.h: Move kadm5_free_name_list() to version 1 api as it is present in the ovsec_glue layer. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13263 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/kadm5/logger.c')
-rw-r--r--src/lib/kadm5/logger.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/lib/kadm5/logger.c b/src/lib/kadm5/logger.c
index bf6bbfd002..3946e7e6c2 100644
--- a/src/lib/kadm5/logger.c
+++ b/src/lib/kadm5/logger.c
@@ -453,7 +453,8 @@ krb5_klog_init(kcontext, ename, whoami, do_com_err)
/*
* Find the end of the severity.
*/
- if (cp2 = strchr(&cp[7], ':')) {
+ cp2 = strchr(&cp[7], ':');
+ if (cp2) {
savec = *cp2;
*cp2 = '\0';
cp2++;
@@ -610,8 +611,9 @@ krb5_klog_init(kcontext, ename, whoami, do_com_err)
* Is this a standard error specification?
*/
else if (!strcasecmp(cp, "STDERR")) {
- if (log_control.log_entries[i].lfu_filep =
- fdopen(fileno(stderr), "a+")) {
+ log_control.log_entries[i].lfu_filep =
+ fdopen(fileno(stderr), "a+");
+ if (log_control.log_entries[i].lfu_filep) {
log_control.log_entries[i].log_type = K_LOG_STDERR;
log_control.log_entries[i].lfu_fname =
"standard error";
@@ -621,8 +623,9 @@ krb5_klog_init(kcontext, ename, whoami, do_com_err)
* Is this a specification of the console?
*/
else if (!strcasecmp(cp, "CONSOLE")) {
- if (log_control.log_entries[i].ldu_filep =
- CONSOLE_OPEN("a+")) {
+ log_control.log_entries[i].ldu_filep =
+ CONSOLE_OPEN("a+");
+ if (log_control.log_entries[i].ldu_filep) {
log_control.log_entries[i].log_type = K_LOG_CONSOLE;
log_control.log_entries[i].ldu_devname = "console";
}
@@ -635,8 +638,9 @@ krb5_klog_init(kcontext, ename, whoami, do_com_err)
* We handle devices very similarly to files.
*/
if (cp[6] == '=') {
- if (log_control.log_entries[i].ldu_filep =
- DEVICE_OPEN(&cp[7], "w")) {
+ log_control.log_entries[i].ldu_filep =
+ DEVICE_OPEN(&cp[7], "w");
+ if (log_control.log_entries[i].ldu_filep) {
log_control.log_entries[i].log_type = K_LOG_DEVICE;
log_control.log_entries[i].ldu_devname = &cp[7];
}
@@ -678,10 +682,15 @@ krb5_klog_init(kcontext, ename, whoami, do_com_err)
log_control.log_nentries = 1;
}
if (log_control.log_nentries) {
- if (log_control.log_whoami = (char *) malloc(strlen(whoami)+1))
+ log_control.log_whoami = (char *) malloc(strlen(whoami)+1);
+ if (log_control.log_whoami)
strcpy(log_control.log_whoami, whoami);
- if (log_control.log_hostname = (char *) malloc(MAXHOSTNAMELEN))
+
+ log_control.log_hostname = (char *) malloc(MAXHOSTNAMELEN + 1);
+ if (log_control.log_hostname) {
gethostname(log_control.log_hostname, MAXHOSTNAMELEN);
+ log_control.log_hostname[MAXHOSTNAMELEN] = '\0';
+ }
#ifdef HAVE_OPENLOG
if (do_openlog) {
openlog(whoami, LOG_NDELAY|LOG_PID, log_facility);