The branch, master has been updated
       via  277f041 passdb: Use talloc_zero_array
       via  0f9669e lib/util: Drop unnecessary use of talloc_tos()
      from  6d450b3 lib/util: Return some functions to util_str.c

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 277f0412e92d40a81ea3e31585fad8881e8c88ba
Author: Volker Lendecke <[email protected]>
Date:   Sat Sep 20 02:08:44 2014 +0200

    passdb: Use talloc_zero_array
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Martin Schwenke <[email protected]>
    
    Autobuild-User(master): Martin Schwenke <[email protected]>
    Autobuild-Date(master): Sat Sep 20 08:29:31 CEST 2014 on sn-devel-104

commit 0f9669eb9f141a9543becf090bd2c9a4a46e1d15
Author: Volker Lendecke <[email protected]>
Date:   Fri Sep 19 16:58:52 2014 +0200

    lib/util: Drop unnecessary use of talloc_tos()
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Martin Schwenke <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 lib/util/util.c           |   10 ++++------
 source3/passdb/pdb_ldap.c |    5 ++---
 2 files changed, 6 insertions(+), 9 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/util/util.c b/lib/util/util.c
index 1dc1f1d..3ba7e4d 100644
--- a/lib/util/util.c
+++ b/lib/util/util.c
@@ -61,7 +61,8 @@ _PUBLIC_ const char *tmpdir(void)
 **/
 int create_unlink_tmp(const char *dir)
 {
-       char *fname;
+       size_t len = strlen(dir);
+       char fname[len+25];
        int fd;
        mode_t mask;
 
@@ -69,8 +70,8 @@ int create_unlink_tmp(const char *dir)
                dir = tmpdir();
        }
 
-       fname = talloc_asprintf(talloc_tos(), "%s/listenerlock_XXXXXX", dir);
-       if (fname == NULL) {
+       len = snprintf(fname, sizeof(fname), "%s/listenerlock_XXXXXX", dir);
+       if (len >= sizeof(fname)) {
                errno = ENOMEM;
                return -1;
        }
@@ -78,17 +79,14 @@ int create_unlink_tmp(const char *dir)
        fd = mkstemp(fname);
        umask(mask);
        if (fd == -1) {
-               TALLOC_FREE(fname);
                return -1;
        }
        if (unlink(fname) == -1) {
                int sys_errno = errno;
                close(fd);
-               TALLOC_FREE(fname);
                errno = sys_errno;
                return -1;
        }
-       TALLOC_FREE(fname);
        return fd;
 }
 
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
index 7dccc03..0458e56 100644
--- a/source3/passdb/pdb_ldap.c
+++ b/source3/passdb/pdb_ldap.c
@@ -855,13 +855,12 @@ static bool init_sam_from_ldap(struct ldapsam_privates 
*ldap_state,
 
                pwHistLen = MIN(pwHistLen, MAX_PW_HISTORY_LEN);
 
-               pwhist = talloc_array(ctx, uint8,
-                                     pwHistLen * PW_HISTORY_ENTRY_LEN);
+               pwhist = talloc_zero_array(ctx, uint8,
+                                          pwHistLen * PW_HISTORY_ENTRY_LEN);
                if (pwhist == NULL) {
                        DEBUG(0, ("init_sam_from_ldap: talloc failed!\n"));
                        goto fn_exit;
                }
-               memset(pwhist, '\0', pwHistLen * PW_HISTORY_ENTRY_LEN);
 
                if (smbldap_get_single_attribute(
                                ldap_state->smbldap_state->ldap_struct,


-- 
Samba Shared Repository

Reply via email to