From 8443e8221afaf1505fd343a7ae9d0e70f1d67326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Tue, 9 Aug 2005 09:28:39 +0000 Subject: [PATCH] (DB_open): catch errors from the d->open calls instead of letting them slip though to d->cursor. Bug repport from Andrew Bartlett git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15853 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/hdb/db3.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/hdb/db3.c b/lib/hdb/db3.c index 860c15041..5406fac6d 100644 --- a/lib/hdb/db3.c +++ b/lib/hdb/db3.c @@ -267,23 +267,27 @@ DB_open(krb5_context context, HDB *db, int flags, mode_t mode) } db_create(&d, NULL, 0); db->hdb_db = d; + #if (DB_VERSION_MAJOR >= 4) && (DB_VERSION_MINOR >= 1) - if ((ret = d->open(db->hdb_db, NULL, fn, NULL, DB_BTREE, myflags, mode))) { + ret = d->open(db->hdb_db, NULL, fn, NULL, DB_BTREE, myflags, mode); #else - if ((ret = d->open(db->hdb_db, fn, NULL, DB_BTREE, myflags, mode))) { + ret = d->open(db->hdb_db, fn, NULL, DB_BTREE, myflags, mode); #endif - if(ret == ENOENT) + + if (ret == ENOENT) { /* try to open without .db extension */ #if (DB_VERSION_MAJOR >= 4) && (DB_VERSION_MINOR >= 1) - if (d->open(db->hdb_db, NULL, db->hdb_name, NULL, DB_BTREE, myflags, mode)) { + ret = d->open(db->hdb_db, NULL, db->hdb_name, NULL, DB_BTREE, myflags, mode); #else - if (d->open(db->hdb_db, db->hdb_name, NULL, DB_BTREE, myflags, mode)) { + ret = d->open(db->hdb_db, db->hdb_name, NULL, DB_BTREE, myflags, mode); #endif - free(fn); - krb5_set_error_string(context, "opening %s: %s", - db->hdb_name, strerror(ret)); - return ret; - } + } + + if (ret) { + free(fn); + krb5_set_error_string(context, "opening %s: %s", + db->hdb_name, strerror(ret)); + return ret; } free(fn);