Переглянути джерело

Ticket #47660 - config_set_allowed_to_delete_attrs: Valgrind reports Invalid read

Description: There was a logic error in checking the availability of
a pointer.  Before checking the contents of an address, the correctness
of the pointer needed to be checked.

Also, one memory leak was found in the error return case.

Note: these 2 issues were introduece by this commit:
commit 94b123780b21e503b78bceca9d60904206ef91fa
Trac Ticket #447 - Possible to add invalid attribute to nsslapd-allowed-to-delete-attrs

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

Reviewed by [email protected] (Thank you, Rich!)
Noriko Hosoi 12 роки тому
батько
коміт
1a788bf35a
1 змінених файлів з 2 додано та 1 видалено
  1. 2 1
      ldap/servers/slapd/libglobs.c

+ 2 - 1
ldap/servers/slapd/libglobs.c

@@ -6760,7 +6760,7 @@ config_set_allowed_to_delete_attrs( const char *attrname, char *value,
         int needcopy = 0;
         allowed = slapi_str2charray_ext(vcopy, " ", 0);
         for (s = allowed; s && *s; s++) ;
-        for (--s; s && *s && (s >= allowed); s--) {
+        for (--s; s && (s >= allowed) && *s; s--) {
             cgas = (struct config_get_and_set *)PL_HashTableLookup(confighash,
                                                                    *s);
             if (!cgas && PL_strcasecmp(*s, "aci") /* aci is an exception */) {
@@ -6781,6 +6781,7 @@ config_set_allowed_to_delete_attrs( const char *attrname, char *value,
                 slapi_log_error(SLAPI_LOG_FATAL, "config",
                         "%s: Given attributes are all invalid.  No effects.\n",
                         CONFIG_ALLOWED_TO_DELETE_ATTRIBUTE);
+                slapi_ch_array_free(allowed);
                 return LDAP_NO_SUCH_ATTRIBUTE;
             } else {
                 for (s = allowed, d = vcopy; s && *s; s++) {