cyrus-sasl-2.1.22 BerkeleyDB version check
Howard Chu
hyc at highlandsun.com
Wed Nov 29 06:04:48 EST 2006
We're getting a lot of crashes reported by users who linked OpenLDAP and
libsasl2 with different versions of BerkeleyDB. It would probably help
if the sasldb code had the same kind of version check that we use in our
code, so that the problem can be caught immediately instead of
mysteriously arising somewhere during runtime.
--
-- Howard Chu
Chief Architect, Symas Corp. http://www.symas.com
Director, Highland Sun http://highlandsun.com/hyc
OpenLDAP Core Team http://www.openldap.org/project/
-------------- next part --------------
Index: db_berkeley.c
===================================================================
RCS file: /cvs/src/sasl/sasldb/db_berkeley.c,v
retrieving revision 1.8
diff -u -r1.8 db_berkeley.c
--- db_berkeley.c 3 Apr 2006 10:58:19 -0000 1.8
+++ db_berkeley.c 29 Nov 2006 11:01:42 -0000
@@ -70,6 +70,28 @@
void *cntxt;
sasl_getopt_t *getopt;
+ { /* version check */
+ int major, minor, patch, ver;
+ char *version = db_version( &major, &minor, &patch );
+
+#ifndef DB_VERSION_FULL
+#define DB_VERSION_FULL ((DB_VERSION_MAJOR<<24)|(DB_VERSION_MINOR<<16)|DB_VERSION_PATCH)
+#endif
+
+ ver = (major << 24) | (minor << 16) | patch;
+ if( ver != DB_VERSION_FULL ) {
+ /* fail if a versions don't match */
+ utils->log(conn, SASL_LOG_ERR,
+ "sasldb: BDB library version mismatch:"
+ " expected " DB_VERSION_STRING ","
+ " got %s\n", version, 0, 0 );
+ utils->seterror(conn, SASL_NOLOG, "BDB library version mismatch.");
+ return SASL_FAIL;
+ }
+
+ utils->log( conn, SASL_LOG_TRACE, "sasldb: %s\n", version );
+ }
+
#if defined(KEEP_DB_OPEN)
if (g_db) {
*mbdb = g_db;
More information about the Cyrus-sasl
mailing list