From 5b7b7f4f01c2a90ece0080cde9a3dde1238f3788 Mon Sep 17 00:00:00 2001 From: Ezra Peisach Date: Mon, 4 Jun 2001 15:28:21 +0000 Subject: [PATCH] * 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 --- src/lib/kadm5/ChangeLog | 12 ++++++++++++ src/lib/kadm5/admin.h | 2 +- src/lib/kadm5/logger.c | 27 ++++++++++++++++++--------- src/lib/kadm5/str_conv.c | 8 +++++--- 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/src/lib/kadm5/ChangeLog b/src/lib/kadm5/ChangeLog index 0b2b5dcc5..25ee6af38 100644 --- a/src/lib/kadm5/ChangeLog +++ b/src/lib/kadm5/ChangeLog @@ -1,3 +1,15 @@ +2001-06-04 Ezra Peisach + + * 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. + 2001-03-10 Ezra Peisach * str_conv.c: Include adm_proto.h for missing prototypes. diff --git a/src/lib/kadm5/admin.h b/src/lib/kadm5/admin.h index f99743e6b..fe21282fd 100644 --- a/src/lib/kadm5/admin.h +++ b/src/lib/kadm5/admin.h @@ -442,10 +442,10 @@ kadm5_ret_t kadm5_get_policies(void *server_handle, kadm5_ret_t kadm5_free_key_data(void *server_handle, krb5_int16 *n_key_data, krb5_key_data *key_data); +#endif kadm5_ret_t kadm5_free_name_list(void *server_handle, char **names, int count); -#endif #if USE_KADM5_API_VERSION == 1 /* diff --git a/src/lib/kadm5/logger.c b/src/lib/kadm5/logger.c index bf6bbfd00..3946e7e6c 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); diff --git a/src/lib/kadm5/str_conv.c b/src/lib/kadm5/str_conv.c index 3bf36a1ec..99334e83c 100644 --- a/src/lib/kadm5/str_conv.c +++ b/src/lib/kadm5/str_conv.c @@ -335,8 +335,9 @@ krb5_string_to_keysalts(string, tupleseps, ksaltseps, dups, ksaltp, nksaltp) len = (size_t) *nksaltp; /* Get new keysalt array */ - if (*ksaltp = (krb5_key_salt_tuple *) - malloc((len + 1) * sizeof(krb5_key_salt_tuple))) { + *ksaltp = (krb5_key_salt_tuple *) + malloc((len + 1) * sizeof(krb5_key_salt_tuple)); + if (*ksaltp) { /* Copy old keysalt if appropriate */ if (savep) { @@ -392,7 +393,8 @@ krb5_keysalt_iterate(ksaltlist, nksalt, ignoresalt, iterator, arg) i, scratch.ks_enctype, scratch.ks_salttype)) { - if (kret = (*iterator)(&scratch, arg)) + kret = (*iterator)(&scratch, arg); + if (kret) break; } } -- 2.26.2