r14147: Fix coverity #119. alloc'ed memory returned not saved, so not freed.
authorJim McDonough <jmcd@samba.org>
Fri, 10 Mar 2006 13:33:02 +0000 (13:33 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 16:15:13 +0000 (11:15 -0500)
Need to go back and correct the assumption that an "ldap xxx suffix"
parm must have an OU.
(This used to be commit 2d7ba11ffbe17af12257a91638be95d09c0c34c5)

source3/utils/net_rpc_samsync.c

index e31525b2eaaa382a1003de725a53167541cf5363..5ee0b702781995fdfbdd11982a3f313ad6a152d0 100644 (file)
@@ -1076,11 +1076,15 @@ static NTSTATUS populate_ldap_for_ldif(fstring sid, const char *suffix, const ch
        if (machine_suffix && *machine_suffix && 
            strcmp(machine_suffix, user_suffix) &&
            strcmp(machine_suffix, suffix)) {
-               fprintf(add_fd, "# %s\n", lp_ldap_machine_suffix());
-               fprintf(add_fd, "dn: %s\n", lp_ldap_machine_suffix());
+               char *machine_ou = NULL;
+               fprintf(add_fd, "# %s\n", machine_suffix);
+               fprintf(add_fd, "dn: %s\n", machine_suffix);
                fprintf(add_fd, "objectClass: organizationalUnit\n");
-               fprintf(add_fd, "ou: %s\n", 
-                       sstring_sub(lp_ldap_machine_suffix(), '=', ','));
+               /* this isn't totally correct as it assumes that
+                  there _must_ be an ou. just fixing memleak now. jmcd */
+               machine_ou = sstring_sub(lp_ldap_machine_suffix(), '=', ',');
+               fprintf(add_fd, "ou: %s\n", machine_ou);
+               SAFE_FREE(machine_ou);
                fprintf(add_fd, "\n");
                fflush(add_fd);
        }