[Date Prev][Date Next] [Chronological] [Thread] [Top]

(ITS#4662) ldap_create needs lock?

Full_Name: Bernie Volz
Version: All
OS: Linux
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (

In ldap_create, if multiple threads are calling ldap_init (or one of the other
initialization functions), they may compete to initialize the global options and
this results in a segmentation fault.

	*ldp = NULL;
	/* Get pointer to global option structure */
	if ( (gopts = LDAP_INT_GLOBAL_OPT()) == NULL) {
		return LDAP_NO_MEMORY;

	/* Initialize the global options, if not already done. */
	if( gopts->ldo_valid != LDAP_INITIALIZED ) {
		ldap_int_initialize(gopts, NULL);
		if ( gopts->ldo_valid != LDAP_INITIALIZED )

Shouldn't the above code be conditionalized on LDAP_R_COMPILE and use a static
global mutex to assure that only one thread is testing and potentially
initializing the global options.