krb5 commit: Fix policy DB fallback error handling
[email protected] Wed, 4 Jan 2023 14:07:05 -0500 (EST)
| Newsgroups | gmane.comp.encryption.kerberos.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://github.com/krb5/krb5/commit/650fe8423a47c52b4b347b47cb41259e04e90092 commit 650fe8423a47c52b4b347b47cb41259e04e90092 Author: Greg Hudson <[email protected]> Date: Mon Dec 12 14:36:47 2022 -0500 Fix policy DB fallback error handling In osa_adb_open_and_lock(), if the btree dbopen() call returns EINVAL or EFTYPE and the fallback hash dbopen() call also returns an error, release the lock and return an error instead of returning success with a null database. ticket: 9082 (new) src/plugins/kdb/db2/adb_openclose.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/plugins/kdb/db2/adb_openclose.c b/src/plugins/kdb/db2/adb_openclose.c index 7db30a33b..9a506e9d4 100644 --- a/src/plugins/kdb/db2/adb_openclose.c +++ b/src/plugins/kdb/db2/adb_openclose.c @@ -327,18 +327,13 @@ osa_adb_open_and_lock(osa_adb_princ_t db, int locktype) goto open_ok; db->db = dbopen(db->filename, O_RDWR, 0600, DB_BTREE, &db->btinfo); - if (db->db != NULL) - goto open_ok; - if (IS_EFTYPE(errno)) { + if (db->db == NULL && IS_EFTYPE(errno)) db->db = dbopen(db->filename, O_RDWR, 0600, DB_HASH, &db->info); - if (db->db != NULL) - goto open_ok; - } else { - (void) osa_adb_release_lock(db); - if (errno == EINVAL) - return OSA_ADB_BAD_DB; - return errno; + if (db->db == NULL) { + (void)osa_adb_release_lock(db); + return (errno == EINVAL) ? OSA_ADB_BAD_DB : errno; } + open_ok: db->opencnt++; return OSA_ADB_OK;