andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
dc8c34
From a9787f2d1b1ab7a477a22acb8a5e22193f2b4dca Mon Sep 17 00:00:00 2001
dc8c34
From: Noriko Hosoi <nhosoi@totoro.usersys.redhat.com>
dc8c34
Date: Wed, 26 Sep 2012 16:55:39 -0700
dc8c34
Subject: [PATCH 290/305] Coverity defects
dc8c34
dc8c34
13093: Resource leak
dc8c34
Fix description: If udn is allocated in ndn_cache_lookup and it
dc8c34
has no chance to be consumed in ndn_cache_add, udn is released.
dc8c34
dc8c34
(cherry picked from commit 4754fb7da3066119576a115a04470b91c4184257)
dc8c34
dc8c34
Conflicts:
dc8c34
	ldap/servers/slapd/dn.c
dc8c34
dc8c34
(cherry picked from commit c49b03070c275575ba879e4e9cee98fc038ce7e6)
dc8c34
---
dc8c34
 ldap/servers/slapd/dn.c | 15 ++++++++++++---
dc8c34
 1 file changed, 12 insertions(+), 3 deletions(-)
dc8c34
dc8c34
diff --git a/ldap/servers/slapd/dn.c b/ldap/servers/slapd/dn.c
dc8c34
index 53c378a..9c1084f 100644
dc8c34
--- a/ldap/servers/slapd/dn.c
dc8c34
+++ b/ldap/servers/slapd/dn.c
dc8c34
@@ -535,7 +535,7 @@ slapi_dn_normalize_ext(char *src, size_t src_len, char **dest, size_t *dest_len)
dc8c34
     char *ends = NULL;
dc8c34
     char *endd = NULL;
dc8c34
     char *lastesc = NULL;
dc8c34
-    char *udn;
dc8c34
+    char *udn = NULL;
dc8c34
     /* rdn avs for the main DN */
dc8c34
     char *typestart = NULL;
dc8c34
     int rdn_av_count = 0;
dc8c34
@@ -1130,8 +1130,13 @@ bail:
dc8c34
         *d = '\0';
dc8c34
     }
dc8c34
     /* add this dn to the normalized dn cache */
dc8c34
-    if(*dest)
dc8c34
-        ndn_cache_add(udn, src_len, *dest, *dest_len);
dc8c34
+    if (udn) {
dc8c34
+        if(dest && *dest && dest_len && *dest_len) {
dc8c34
+            ndn_cache_add(udn, src_len, *dest, *dest_len);
dc8c34
+        } else {
dc8c34
+            slapi_ch_free_string(&udn;;
dc8c34
+        }
dc8c34
+    }
dc8c34
 
dc8c34
     return rc;
dc8c34
 }
dc8c34
@@ -2774,6 +2779,10 @@ ndn_cache_lookup(char *dn, size_t dn_len, char **result, char **udn, int *rc)
dc8c34
     char *ndn, *key;
dc8c34
     int rv = 0;
dc8c34
 
dc8c34
+    if(NULL == udn){
dc8c34
+        return rv;
dc8c34
+    }
dc8c34
+    *udn = NULL;
dc8c34
     if(ndn_started == 0){
dc8c34
         return rv;
dc8c34
     }
dc8c34
-- 
dc8c34
1.9.3
dc8c34