diff options
author | Noriko Hosoi <nhosoi@redhat.com> | 2010-08-23 14:58:24 -0700 |
---|---|---|
committer | Noriko Hosoi <nhosoi@redhat.com> | 2010-08-23 14:58:24 -0700 |
commit | 4fb9a3f93e7f5d64c8ae7a7d2e0b22451c2c7efe (patch) | |
tree | 5e9d4317a8576eec4de405c9b4ea849518b2b028 /ldap | |
parent | ee4dc5e8a3b99be79af9556689950a4936b9f968 (diff) | |
download | ds-4fb9a3f93e7f5d64c8ae7a7d2e0b22451c2c7efe.tar.gz ds-4fb9a3f93e7f5d64c8ae7a7d2e0b22451c2c7efe.tar.xz ds-4fb9a3f93e7f5d64c8ae7a7d2e0b22451c2c7efe.zip |
Bug 611790 - fix coverify Defect Type: Null pointer dereferences issues 11940 - 12166
https://bugzilla.redhat.com/show_bug.cgi?id=611790
Resolves: bug 611790
Bug description: Fix coverify Defect Type: Null pointer dereferences issues 11940 - 12166
Fix description: Catch possible NULL pointer in acl_match_macro_in_target().
Diffstat (limited to 'ldap')
-rw-r--r-- | ldap/servers/plugins/acl/aclutil.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/ldap/servers/plugins/acl/aclutil.c b/ldap/servers/plugins/acl/aclutil.c index 496e655d..e1eb0ab1 100644 --- a/ldap/servers/plugins/acl/aclutil.c +++ b/ldap/servers/plugins/acl/aclutil.c @@ -286,7 +286,7 @@ aclutil_print_err (int rv , const Slapi_DN *sdn, const struct berval* val, } slapi_log_error( SLAPI_LOG_FATAL, plugin_name, "%s", lineptr); - if (newline) slapi_ch_free((void **) &newline); + slapi_ch_free_string(&newline); } /*************************************************************************** @@ -549,7 +549,7 @@ aclutil_expand_paramString ( char *str, Slapi_Entry *e ) char **a_dns; char *attrName; char *s, *p; - char *attrVal; + char *attrVal = NULL; int i, len; int ncomponents, type; int rc = -1; @@ -635,8 +635,7 @@ cleanup: slapi_ldap_value_free ( a_dns ); slapi_ldap_value_free ( e_dns ); if ( 0 != rc ) /* error */ { - slapi_ch_free ( (void **) &buf ); - buf = NULL; + slapi_ch_free_string ( &buf ); } return buf; @@ -779,11 +778,19 @@ acl_match_macro_in_target( const char *ndn, char * match_this, /* we know it's got a $(dn) */ tmp_ptr = strstr(macro_prefix, ACL_TARGET_MACRO_DN_KEY); + if (!tmp_ptr) { + LDAPDebug(LDAP_DEBUG_ACL,"acl_match_macro_in_target: " + "Target macro DN key \"%s\" not found in \"%s\".\n", + ACL_TARGET_MACRO_DN_KEY, macro_prefix, 0); + slapi_ch_free_string(¯o_prefix); + return ret_val; + } + *tmp_ptr = '\0'; /* There may be a NULL prefix eg. match_this: ($dn),o=sun.com */ macro_prefix_len = strlen(macro_prefix); if (macro_prefix_len == 0) { - slapi_ch_free((void **) ¯o_prefix); + slapi_ch_free_string(¯o_prefix); macro_prefix = NULL; } @@ -950,7 +957,7 @@ acl_match_macro_in_target( const char *ndn, char * match_this, } } }/* contains an =* */ - slapi_ch_free((void **) ¯o_prefix); + slapi_ch_free_string(¯o_prefix); }/* macro_prefix != NULL */ return(ret_val); @@ -1119,7 +1126,7 @@ acl_match_prefix( char *macro_prefix, const char *ndn, int *exact_match) { } } } - slapi_ch_free((void **)&tmp_str); + slapi_ch_free_string(&tmp_str); } }/* while */ @@ -1211,13 +1218,13 @@ acl_strstr(char * s, char *substr) { tmp_str = slapi_ch_strdup(s); if ( (t = strstr(tmp_str, substr)) == NULL ) { - slapi_ch_free((void **)&tmp_str); + slapi_ch_free_string(&tmp_str); return(-1); } else { int l = 0; *t = '\0'; l = strlen(tmp_str); - slapi_ch_free((void **)&tmp_str); + slapi_ch_free_string(&tmp_str); return(l); } } @@ -1268,7 +1275,7 @@ acl_replace_str(char * s, char *substr, char* replace_with_str) { strcat(patched, replace_with_str); strcat(patched, suffix); - slapi_ch_free((void **)&working_s); + slapi_ch_free_string(&working_s); working_s = patched; prefix = working_s; @@ -1379,7 +1386,7 @@ void acl_ht_add_and_freeOld(acl_ht_t * acl_ht, if ( (old_value = (char *)acl_ht_lookup( acl_ht, key)) != NULL ) { acl_ht_remove( acl_ht, key); - slapi_ch_free((void **)&old_value); + slapi_ch_free_string(&old_value); } PL_HashTableAdd( acl_ht, (const void *)pkey, value); |