From: Tom Yu Date: Mon, 17 Mar 1997 02:22:52 +0000 (+0000) Subject: * keytab.c: Don't assume dbm_db_get_mkey() and dbe_find_enctype X-Git-Tag: krb5-1.1-beta1~1191 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=74aea346f83e259a55e95fc8e3dd92420de8dacc;p=krb5.git * keytab.c: Don't assume dbm_db_get_mkey() and dbe_find_enctype won't error out. Also, some gcc -Wall warning cleanups. [krb5-kdc/361] git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@10004 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/kdb/ChangeLog b/src/lib/kdb/ChangeLog index 1ecea6a6f..7693dc1f4 100644 --- a/src/lib/kdb/ChangeLog +++ b/src/lib/kdb/ChangeLog @@ -1,3 +1,9 @@ +Sun Mar 16 21:20:00 1997 Tom Yu + + * keytab.c: Don't assume dbm_db_get_mkey() and dbe_find_enctype + won't error out. Also, some gcc -Wall warning + cleanups. [krb5-kdc/361] + Sat Feb 22 01:15:30 1997 Sam Hartman * Makefile.in (SHLIB_EXPLIBS): depend on -lcrypto diff --git a/src/lib/kdb/keytab.c b/src/lib/kdb/keytab.c index c32b74217..82ed08e33 100644 --- a/src/lib/kdb/keytab.c +++ b/src/lib/kdb/keytab.c @@ -110,35 +110,44 @@ krb5_ktkdb_get_entry(context, id, principal, kvno, enctype, entry) /* Open database */ /* krb5_dbm_db_init(context); */ - if (kerror = krb5_dbm_db_open_database(context)) + if ((kerror = krb5_dbm_db_open_database(context))) return(kerror); /* get_principal */ - if (kerror = krb5_dbm_db_get_principal(context, principal, &db_entry, - &n, &more)) { + kerror = krb5_dbm_db_get_principal(context, principal, & + db_entry, &n, &more); + if (kerror) { krb5_dbm_db_close_database(context); return(kerror); } - - if (n != 1) - { + if (n != 1) { krb5_dbm_db_close_database(context); return KRB5_KT_NOTFOUND; - } + } + /* match key */ - krb5_dbm_db_get_mkey(context, id->ops, &master_key); - krb5_dbe_find_enctype(context, &db_entry, enctype, -1, kvno, &key_data); - if (kerror = krb5_dbekd_decrypt_key_data(context, master_key, key_data, - &entry->key, NULL)) + /* WTF??? 2nd arg to dbm_db_get_mkey appears to be unused! -tlyu */ + kerror = krb5_dbm_db_get_mkey(context, id->ops, &master_key); + if (kerror) + goto error; + + kerror = krb5_dbe_find_enctype(context, &db_entry, + enctype, -1, kvno, &key_data); + if (kerror) + goto error; + + kerror = krb5_dbekd_decrypt_key_data(context, master_key, + key_data, &entry->key, NULL); + if (kerror) goto error; - if (kerror = krb5_copy_principal(context, principal, &entry->principal)) + kerror = krb5_copy_principal(context, principal, &entry->principal); + if (kerror) goto error; /* Close database */ -error:; + error: krb5_dbe_free_contents(context, &db_entry); krb5_dbm_db_close_database(context); return(kerror); } -