cyrus-sasl-2.1.22 BerkeleyDB version check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/

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;

[Index of Archives]     [Info Cyrus]     [Squirrel Mail]     [Linux Media]     [Yosemite News]     [gtk]     [KDE]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux