Don't clear the key and alt_key structures prematurely when adding a principal
authorTheodore Tso <tytso@mit.edu>
Thu, 13 Jan 1994 23:45:34 +0000 (23:45 +0000)
committerTheodore Tso <tytso@mit.edu>
Thu, 13 Jan 1994 23:45:34 +0000 (23:45 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@3323 dc483132-0cff-0310-8789-dd5450dbe970

src/kadmin/server/adm_funcs.c

index 99e1aecdc89bcfdf18c64052a69bdc3123a516c6..9c1c5fce4b68b178a74d85e513782d53d4b29c3b 100644 (file)
@@ -170,6 +170,23 @@ OLDDECLARG(krb5_db_entry *, entry)
     krb5_timestamp KDB5_EXP_DATE  = KRB5_KDB_EXPIRATION;
     extern krb5_flags NEW_ATTRIBUTES;
 
+    if (!req_type) { /* New entry - initialize */
+       memset((char *) entry, 0, sizeof(*entry));
+        entry->principal = (krb5_principal) principal;
+        entry->kvno = KDB5_VERSION_NUM;
+        entry->max_life = KDB5_MAX_TKT_LIFE;
+        entry->max_renewable_life = KDB5_MAX_REN_LIFE;
+        entry->mkvno = mblock.mkvno;
+        entry->expiration = KDB5_EXP_DATE;
+        entry->mod_name = master_princ;
+    } else { /* Modify existing entry */
+       entry->kvno++;
+#ifdef SANDIA
+       entry->attributes &= ~KRB5_KDB_REQUIRES_PWCHANGE;
+#endif
+       entry->mod_name = (krb5_principal) principal;
+    }
+
     if (key && key->length) {
        retval = krb5_kdb_encrypt_key(&master_encblock,
                                      key,
@@ -192,23 +209,6 @@ OLDDECLARG(krb5_db_entry *, entry)
        }
     }
 
-    if (!req_type) { /* New entry - initialize */
-       memset((char *) entry, 0, sizeof(*entry));
-        entry->principal = (krb5_principal) principal;
-        entry->kvno = KDB5_VERSION_NUM;
-        entry->max_life = KDB5_MAX_TKT_LIFE;
-        entry->max_renewable_life = KDB5_MAX_REN_LIFE;
-        entry->mkvno = mblock.mkvno;
-        entry->expiration = KDB5_EXP_DATE;
-        entry->mod_name = master_princ;
-    } else { /* Modify existing entry */
-       entry->kvno++;
-#ifdef SANDIA
-       entry->attributes &= ~KRB5_KDB_REQUIRES_PWCHANGE;
-#endif
-       entry->mod_name = (krb5_principal) principal;
-    }
-
     if (retval = krb5_timeofday(&entry->mod_date)) {
        com_err("adm_modify_kdb", retval, "while fetching date");
        memset((char *) entry->key.contents, 0, entry->key.length);