[389-commits] Branch '389-ds-base-1.3.3' - ldap/servers

Noriko Hosoi nhosoi at fedoraproject.org
Tue Sep 9 21:47:04 UTC 2014


 ldap/servers/slapd/tools/migratecred.c       |   13 ++++++++++++-
 ldap/servers/slapd/tools/rsearch/nametable.c |   13 ++++++++-----
 2 files changed, 20 insertions(+), 6 deletions(-)

New commits:
commit aa8ff4b066243f68175f2e664239b7db8747e1d1
Author: Noriko Hosoi <nhosoi at redhat.com>
Date:   Tue Sep 9 14:27:40 2014 -0700

    Ticket #47890 - minor memory leaks in utilities
    
    Description:
    tools/rsearch/nametable.c - if nt_push fails and the strdup'ed
                                string is not pushed to the table,
                                free the string.
    tools/migratecred.c - free strdup'ed strings oldpath, newpath,
                          prefixCred, and pluginpath at the end of
                          the process.
    
    https://fedorahosted.org/389/ticket/47890
    
    Reviewed by mreynolds at redhat.com (Thank you, Mark!!)
    
    (cherry picked from commit 1279f0e0fe1d0f5456e42ef5b7a9f395f793cc9e)

diff --git a/ldap/servers/slapd/tools/migratecred.c b/ldap/servers/slapd/tools/migratecred.c
index 085a21a..c1e37bf 100644
--- a/ldap/servers/slapd/tools/migratecred.c
+++ b/ldap/servers/slapd/tools/migratecred.c
@@ -163,6 +163,10 @@ main( int argc, char **argv)
 
 	if ( !oldpath || !newpath || !cred )
 	{
+		free(oldpath);
+		free(newpath);
+		free(prefixCred);
+		free(pluginpath);
 		usage(cmd);
 	}
 
@@ -208,6 +212,10 @@ main( int argc, char **argv)
 			"DES Plugin", 1 /* report errors */ );
 	if ( fct == NULL )
 	{
+		free(oldpath);
+		free(newpath);
+		free(prefixCred);
+		free(pluginpath);
 		usage(cmd);
 		return(1);
 	}
@@ -215,7 +223,10 @@ main( int argc, char **argv)
 	newcred = (fct)(oldpath, newpath, cred);
 
 	fprintf(stdout, "%s", newcred);
-
+	free(oldpath);
+	free(newpath);
+	free(prefixCred);
+	free(pluginpath);
 	return(0);
 	
 }
diff --git a/ldap/servers/slapd/tools/rsearch/nametable.c b/ldap/servers/slapd/tools/rsearch/nametable.c
index e5d04cd..03a6ae1 100644
--- a/ldap/servers/slapd/tools/rsearch/nametable.c
+++ b/ldap/servers/slapd/tools/rsearch/nametable.c
@@ -152,11 +152,14 @@ int nt_load(NameTable *nt, const char *filename)
     if (!fd) return 0;
 
     while (PR_Available(fd) > 0) {
-	char temp[4096], *s;
-	if (PR_GetLine(fd, temp, sizeof(temp))) break;
-	s = strdup(temp);
-	if (!s) break;
-	if (!nt_push(nt, s)) break;
+        char temp[4096], *s;
+        if (PR_GetLine(fd, temp, sizeof(temp))) break;
+        s = strdup(temp);
+        if (!s) break;
+        if (!nt_push(nt, s)) {
+            free(s);
+            break;
+        }
     }
     PR_Close(fd);
     return nt->size;




More information about the 389-commits mailing list