ldap/servers/slapd/attr.c | 1 -
ldap/servers/slapd/search.c | 20 +++++---------------
2 files changed, 5 insertions(+), 16 deletions(-)
New commits:
commit 36c48b8395c6e4ca374c74f91dad6b022aa99ce1
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Mon Jan 13 14:43:46 2014 -0800
Ticket #47571 - targetattr ACIs ignore subtype
Description: commit 85a78741dfeb636a1cf7cced1576278e65f5bb58
introduced 2 coverity issues:
12423: Explicit null dereferenced
do_search (slapd/search.c)
If attribute list contains multiple "*"s and "aci"s in
ldapsearch,
the previous code attempted to add "aci" once for "*" and
replacing
"aci" with normalized aci (if any) once and eliminating the duplicated
"aci"s. The code contained a null dereferenced bug. Even if duplicated
attributes are included in the attribute list, they are removed later
in send_specific_attrs. Thus, this patch simplifies the logic to avoid
the null dereference.
12422: Logically dead code
comp_cmp (slapd/attr.c)
Eliminated the dead code (case s1 == NULL AND s2 == NULL).
https://fedorahosted.org/389/ticket/47571
Reviewed by rmeggins(a)redhat.com (Thank you, Rich!!)
diff --git a/ldap/servers/slapd/attr.c b/ldap/servers/slapd/attr.c
index ef3fa10..39c6e99 100644
--- a/ldap/servers/slapd/attr.c
+++ b/ldap/servers/slapd/attr.c
@@ -111,7 +111,6 @@ comp_cmp( const char *s1p, const char *s2p )
if (s1) {
return 1;
}
- return 0;
}
while ( *s1 && (*s1 != ';') &&
*s2 && (*s2 != ';') &&
diff --git a/ldap/servers/slapd/search.c b/ldap/servers/slapd/search.c
index 29729bb..d68ba7b 100644
--- a/ldap/servers/slapd/search.c
+++ b/ldap/servers/slapd/search.c
@@ -248,11 +248,10 @@ do_search( Slapi_PBlock *pb )
if ( attrs != NULL ) {
char *normaci = slapi_attr_syntax_normalize("aci");
int replace_aci = 0;
- if (0 == strcasecmp(normaci, "aci")) {
- /* normaci is identical to "aci" */
- slapi_ch_free_string(&normaci);
+ if (!normaci) {
normaci = slapi_ch_strdup("aci");
- } else {
+ } else if (strcasecmp(normaci, "aci")) {
+ /* normaci is not "aci" */
replace_aci = 1;
}
/*
@@ -284,20 +283,11 @@ do_search( Slapi_PBlock *pb )
*p = '\0';
} else if (strcmp(attrs[i], LDAP_ALL_USER_ATTRS /* '*' */) == 0) {
if (!charray_inlist(attrs, normaci)) {
- charray_add(&attrs, normaci); /* consumed */
- normaci = NULL;
+ charray_add(&attrs, slapi_ch_strdup(normaci));
}
} else if (replace_aci && (strcasecmp(attrs[i], "aci") == 0)) {
slapi_ch_free_string(&attrs[i]);
- if (charray_inlist(attrs, normaci)) { /* attrlist: "*" "aci" */
- int j = i;
- for (; attrs[j]; j++) { /* Shift the rest by 1 */
- attrs[j] = attrs[j+1];
- }
- } else { /* attrlist: "aci" "*" */
- attrs[i] = normaci; /* consumed */
- normaci = NULL;
- }
+ attrs[i] = slapi_ch_strdup(normaci);
}
}
slapi_ch_free_string(&normaci);