* logger.c (krb5_klog_init): Cleanup assignments in
authorEzra Peisach <epeisach@mit.edu>
Mon, 4 Jun 2001 15:28:21 +0000 (15:28 +0000)
committerEzra Peisach <epeisach@mit.edu>
Mon, 4 Jun 2001 15:28:21 +0000 (15:28 +0000)
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
src/lib/kadm5/admin.h
src/lib/kadm5/logger.c
src/lib/kadm5/str_conv.c

index 0b2b5dcc559f29cc8ca7c766f04e215f0cfe7754..25ee6af383afff25a76a8e12663d1e96846cec32 100644 (file)
@@ -1,3 +1,15 @@
+2001-06-04  Ezra Peisach  <epeisach@mit.edu>
+
+       * 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  <epeisach@kangaroo.mit.edu>
 
        * str_conv.c: Include adm_proto.h for missing prototypes.
index f99743e6b03095fff338e6964a9057c5f640328f..fe21282fd0b8f3158b570d0da0ac4f0c39989523 100644 (file)
@@ -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
 /*
index bf6bbfd0021981235490fa5ea5a5c5c9abae1072..3946e7e6c29b0030765fa7c790f41773a4fd7607 100644 (file)
@@ -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);
index 3bf36a1ecf0c6785305d92a9c6b5ef0f2f25b135..99334e83c3658e05b6fd3a92aff0e0476fa60d2d 100644 (file)
@@ -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;
        }
     }