Blame SOURCES/0079-Ticket-47660-config_set_allowed_to_delete_attrs-Valg.patch

cc3dff
From d30caf438689760dd4fce8dc914070daae47de72 Mon Sep 17 00:00:00 2001
cc3dff
From: Noriko Hosoi <nhosoi@redhat.com>
cc3dff
Date: Mon, 13 Jan 2014 11:03:46 -0800
cc3dff
Subject: [PATCH 79/83] Ticket #47660 - config_set_allowed_to_delete_attrs:
cc3dff
 Valgrind reports Invalid read
cc3dff
cc3dff
Description: There was a logic error in checking the availability of
cc3dff
a pointer.  Before checking the contents of an address, the correctness
cc3dff
of the pointer needed to be checked.
cc3dff
cc3dff
Also, one memory leak was found in the error return case.
cc3dff
cc3dff
Note: these 2 issues were introduece by this commit:
cc3dff
commit 94b123780b21e503b78bceca9d60904206ef91fa
cc3dff
Trac Ticket #447 - Possible to add invalid attribute to nsslapd-allowed-to-delete-attrs
cc3dff
cc3dff
https://fedorahosted.org/389/ticket/47660
cc3dff
cc3dff
Reviewed by rmeggins@redhat.com (Thank you, Rich!)
cc3dff
(cherry picked from commit 1a788bf35a138d221f2bfb88d6da5fc5244d738c)
cc3dff
(cherry picked from commit 22c24f0d133cfcfc9f7457a84282d223ea3f6e25)
cc3dff
(cherry picked from commit 4aa849fa0a32d90e7d88574f35e1e17fbaf1034f)
cc3dff
---
cc3dff
 ldap/servers/slapd/libglobs.c | 3 ++-
cc3dff
 1 file changed, 2 insertions(+), 1 deletion(-)
cc3dff
cc3dff
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
cc3dff
index 6df225d..bcf7db4 100644
cc3dff
--- a/ldap/servers/slapd/libglobs.c
cc3dff
+++ b/ldap/servers/slapd/libglobs.c
cc3dff
@@ -6704,7 +6704,7 @@ config_set_allowed_to_delete_attrs( const char *attrname, char *value,
cc3dff
         int needcopy = 0;
cc3dff
         allowed = slapi_str2charray_ext(vcopy, " ", 0);
cc3dff
         for (s = allowed; s && *s; s++) ;
cc3dff
-        for (--s; s && *s && (s >= allowed); s--) {
cc3dff
+        for (--s; s && (s >= allowed) && *s; s--) {
cc3dff
             cgas = (struct config_get_and_set *)PL_HashTableLookup(confighash,
cc3dff
                                                                    *s);
cc3dff
             if (!cgas && PL_strcasecmp(*s, "aci") /* aci is an exception */) {
cc3dff
@@ -6725,6 +6725,7 @@ config_set_allowed_to_delete_attrs( const char *attrname, char *value,
cc3dff
                 slapi_log_error(SLAPI_LOG_FATAL, "config",
cc3dff
                         "%s: Given attributes are all invalid.  No effects.\n",
cc3dff
                         CONFIG_ALLOWED_TO_DELETE_ATTRIBUTE);
cc3dff
+                slapi_ch_array_free(allowed);
cc3dff
                 return LDAP_NO_SUCH_ATTRIBUTE;
cc3dff
             } else {
cc3dff
                 for (s = allowed, d = vcopy; s && *s; s++) {
cc3dff
-- 
cc3dff
1.8.1.4
cc3dff