diff options
| author | Endi S. Dewata <edewata@redhat.com> | 2010-07-12 23:04:01 -0500 |
|---|---|---|
| committer | Noriko Hosoi <nhosoi@redhat.com> | 2010-08-19 13:00:40 -0700 |
| commit | 3630638348d97e5c28fb2d5413b85f7d2949582e (patch) | |
| tree | 4b3176b055b3f20e89ed0bd51db8b53543968cbd /ldap/servers/plugins/chainingdb | |
| parent | 6c40dc0e962c4197418659b9765bfb4d3b653ec2 (diff) | |
| download | ds-3630638348d97e5c28fb2d5413b85f7d2949582e.tar.gz ds-3630638348d97e5c28fb2d5413b85f7d2949582e.tar.xz ds-3630638348d97e5c28fb2d5413b85f7d2949582e.zip | |
Bug 614511 - fix coverify Defect Type: Null pointer dereferences issues 11846 - 11891
https://bugzilla.redhat.com/show_bug.cgi?id=614511
Resolves: bug 614511
Bug description: Fix coverify Defect Type: Null pointer dereferences issues 11846 - 11891
description: Catch possible NULL pointer in cb_instance_free(), cb_instance_hosturl_set(),
and cb_instance_starttls_set(), cb_instance_bindmech_set(), and cb_instance_config_get().
Diffstat (limited to 'ldap/servers/plugins/chainingdb')
| -rw-r--r-- | ldap/servers/plugins/chainingdb/cb_instance.c | 55 |
1 files changed, 40 insertions, 15 deletions
diff --git a/ldap/servers/plugins/chainingdb/cb_instance.c b/ldap/servers/plugins/chainingdb/cb_instance.c index 73d5e019..b1af028f 100644 --- a/ldap/servers/plugins/chainingdb/cb_instance.c +++ b/ldap/servers/plugins/chainingdb/cb_instance.c @@ -250,16 +250,23 @@ void cb_instance_free(cb_backend_instance * inst) { inst->eq_ctx = NULL; } - if (inst->bind_pool) + if (inst->bind_pool) + { cb_close_conn_pool(inst->bind_pool); + slapi_destroy_condvar(inst->bind_pool->conn.conn_list_cv); + slapi_destroy_mutex(inst->bind_pool->conn.conn_list_mutex); + slapi_ch_free((void **) &inst->bind_pool); + } + if (inst->pool) + { cb_close_conn_pool(inst->pool); + slapi_destroy_condvar(inst->pool->conn.conn_list_cv); + slapi_destroy_mutex(inst->pool->conn.conn_list_mutex); + slapi_ch_free((void **) &inst->pool); + } - slapi_destroy_condvar(inst->bind_pool->conn.conn_list_cv); - slapi_destroy_condvar(inst->pool->conn.conn_list_cv); slapi_destroy_mutex(inst->monitor.mutex); - slapi_destroy_mutex(inst->bind_pool->conn.conn_list_mutex); - slapi_destroy_mutex(inst->pool->conn.conn_list_mutex); slapi_destroy_mutex(inst->monitor_availability.cpt_lock); slapi_destroy_mutex(inst->monitor_availability.lock_timeLimit); slapi_ch_free_string(&inst->configDn); @@ -267,11 +274,7 @@ void cb_instance_free(cb_backend_instance * inst) { slapi_ch_free_string(&inst->inst_name); charray_free(inst->every_attribute); - slapi_ch_free((void **) &inst->bind_pool); - slapi_ch_free((void **) &inst->pool); - PR_RWLock_Unlock(inst->rwl_config_lock); - PR_DestroyRWLock(inst->rwl_config_lock); slapi_ch_free((void **) &inst); @@ -716,14 +719,21 @@ static int cb_instance_hosturl_set(void *arg, void *value, char *errorbuf, int p int rc=LDAP_SUCCESS; int secure = 0; - if (( rc = slapi_ldap_url_parse( url, &ludp, 0, &secure )) != 0 ) { + if (!inst) { + PR_snprintf (errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "NULL instance"); + rc = LDAP_OPERATIONS_ERROR; + goto done; + } + + if (( rc = slapi_ldap_url_parse( url, &ludp, 0, &secure )) != 0 || !ludp) { PL_strncpyz(errorbuf,slapi_urlparse_err2string( rc ), SLAPI_DSE_RETURNTEXT_SIZE); if (CB_CONFIG_PHASE_INITIALIZATION == phase) inst->pool->url=slapi_ch_strdup(""); - return(LDAP_INVALID_SYNTAX); + rc = LDAP_INVALID_SYNTAX; + goto done; } - if (ludp && secure && inst && inst->rwl_config_lock) { + if (secure && inst->rwl_config_lock) { int isgss = 0; PR_RWLock_Rlock(inst->rwl_config_lock); isgss = inst->pool->mech && !PL_strcasecmp(inst->pool->mech, "GSSAPI"); @@ -812,7 +822,7 @@ static int cb_instance_hosturl_set(void *arg, void *value, char *errorbuf, int p PR_RWLock_Unlock(inst->rwl_config_lock); } - +done: if ( ludp != NULL ) { ldap_free_urldesc( ludp ); } @@ -1358,7 +1368,13 @@ static int cb_instance_starttls_set(void *arg, void *value, char *errorbuf, int cb_backend_instance * inst=(cb_backend_instance *) arg; int rc = LDAP_SUCCESS; - if (value && inst && inst->rwl_config_lock) { + if (!inst) { + PR_snprintf (errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "NULL instance"); + rc = LDAP_OPERATIONS_ERROR; + goto done; + } + + if (value && inst->rwl_config_lock) { int isgss = 0; PR_RWLock_Rlock(inst->rwl_config_lock); isgss = inst->pool->mech && !PL_strcasecmp(inst->pool->mech, "GSSAPI"); @@ -1378,6 +1394,7 @@ static int cb_instance_starttls_set(void *arg, void *value, char *errorbuf, int rc=CB_REOPEN_CONN; /* reconnect with the new starttls setting */ } } +done: return rc; } @@ -1397,7 +1414,13 @@ static int cb_instance_bindmech_set(void *arg, void *value, char *errorbuf, int cb_backend_instance * inst=(cb_backend_instance *) arg; int rc=LDAP_SUCCESS; - if (value && !PL_strcasecmp((char *) value, "GSSAPI") && inst && inst->rwl_config_lock) { + if (!inst) { + PR_snprintf (errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "NULL instance"); + rc = LDAP_OPERATIONS_ERROR; + goto done; + } + + if (value && !PL_strcasecmp((char *) value, "GSSAPI") && inst->rwl_config_lock) { int secure = 0; PR_RWLock_Rlock(inst->rwl_config_lock); secure = inst->pool->secure || inst->pool->starttls; @@ -1427,6 +1450,7 @@ static int cb_instance_bindmech_set(void *arg, void *value, char *errorbuf, int } PR_RWLock_Unlock(inst->rwl_config_lock); } +done: return rc; } @@ -1537,6 +1561,7 @@ void cb_instance_config_get(void *arg, cb_instance_config_info *config, char *bu if (config == NULL) { buf[0] = '\0'; + return; } switch(config->config_type) { |
