Browse Source

Ticket #48279 - Check NULL reference in nssasl_mutex_lock etc. (saslbind.c)

Description: Some SASL subsystem are thread safe and do not require
locking.  This may call callbacks in saslbind.c with NULL mutex.
This patch adds NULL checking before calling PR_.*[Ll]ock.

https://fedorahosted.org/389/ticket/48279

Reviewed by [email protected] (Thank you, Mark!!)
Noriko Hosoi 10 years ago
parent
commit
fba0194810
1 changed files with 12 additions and 4 deletions
  1. 12 4
      ldap/servers/slapd/saslbind.c

+ 12 - 4
ldap/servers/slapd/saslbind.c

@@ -35,19 +35,27 @@ void *nssasl_mutex_alloc(void)
 
 int nssasl_mutex_lock(void *mutex)
 {
-    PR_Lock(mutex);
+    if (mutex) {
+        PR_Lock(mutex);
+    }
     return SASL_OK;
 }
 
 int nssasl_mutex_unlock(void *mutex)
 {
-    if (PR_Unlock(mutex) == PR_SUCCESS) return SASL_OK;
-    return SASL_FAIL;
+    if (mutex) {
+        if (PR_Unlock(mutex) == PR_SUCCESS) return SASL_OK;
+        return SASL_FAIL;
+    } else {
+        return SASL_OK;
+    }
 }
 
 void nssasl_mutex_free(void *mutex)
 {
-    PR_DestroyLock(mutex);
+    if (mutex) {
+        PR_DestroyLock(mutex);
+    }
 }
 
 void nssasl_free(void *ptr)