r2654: fixed some more server memory leaks. We are now down to a single leak
authorAndrew Tridgell <tridge@samba.org>
Sun, 26 Sep 2004 06:44:08 +0000 (06:44 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:59:17 +0000 (12:59 -0500)
of 16 bytes, caused by the 16 byte data_blob in the smb_signing
code.

source/auth/auth_sam.c
source/libcli/cliconnect.c
source/libcli/raw/clisession.c
source/libcli/raw/clisocket.c
source/libcli/raw/clitransport.c
source/libcli/raw/clitree.c
source/libcli/raw/rawrequest.c
source/ntvfs/posix/vfs_posix.c
source/smbd/process_standard.c

index 8c86328c05f9499e98521084f8a2bdd7d523424d..6ddddafee325b5db1dad81b75b83748ad0dabd7d 100644 (file)
@@ -39,6 +39,8 @@ static NTSTATUS sam_password_ok(const struct auth_context *auth_context,
                                DATA_BLOB *user_sess_key, 
                                DATA_BLOB *lm_sess_key)
 {
+       NTSTATUS status;
+
        if (acct_flags & ACB_PWNOTREQ) {
                if (lp_null_passwords()) {
                        DEBUG(3,("Account for user '%s' has no password and null passwords are allowed.\n", 
@@ -51,7 +53,7 @@ static NTSTATUS sam_password_ok(const struct auth_context *auth_context,
                }               
        }
 
-       return ntlm_password_check(mem_ctx, &auth_context->challenge, 
+       status = ntlm_password_check(mem_ctx, &auth_context->challenge, 
                                   &user_info->lm_resp, &user_info->nt_resp, 
                                   &user_info->lm_interactive_password, 
                                   &user_info->nt_interactive_password,
@@ -59,6 +61,17 @@ static NTSTATUS sam_password_ok(const struct auth_context *auth_context,
                                   user_info->smb_name.str, 
                                   user_info->client_domain.str, 
                                   lm_pwd->hash, nt_pwd->hash, user_sess_key, lm_sess_key);
+
+       if (NT_STATUS_IS_OK(status)) {
+               if (user_sess_key && user_sess_key->data) {
+                       talloc_steal(auth_context, user_sess_key->data);
+               }
+               if (lm_sess_key && lm_sess_key->data) {
+                       talloc_steal(auth_context, lm_sess_key->data);
+               }
+       }
+
+       return status;
 }
 
 
@@ -330,8 +343,7 @@ static NTSTATUS check_sam_security(const struct auth_context *auth_context,
                }
                
                if (group_ret > 0 && 
-                   !(groupSIDs = talloc_realloc_p(groupSIDs, 
-                                                  struct dom_sid *, group_ret))) {
+                   !(groupSIDs = talloc_array_p(*server_info, struct dom_sid *, group_ret))) {
                        talloc_free(*server_info);
                        return NT_STATUS_NO_MEMORY;
                }
index 66882f605d6a2c9b34b692379fe12bd4867046dc..27caaa9df99000d35f0cea752e0efeded43491e1 100644 (file)
@@ -211,7 +211,7 @@ struct smbcli_state *smbcli_state_init(void)
 {
        struct smbcli_state *cli;
 
-       cli = talloc_named(NULL, sizeof(*cli), "smbcli_state");
+       cli = talloc_p(NULL, struct smbcli_state);
        if (cli) {
                ZERO_STRUCTP(cli);
        }
index 37992968a4da7e3befcf908bffef2d6fb39c6088..75b964501870a50b946562821b37f8fa4052dc91 100644 (file)
@@ -33,7 +33,7 @@ struct smbcli_session *smbcli_session_init(struct smbcli_transport *transport)
 {
        struct smbcli_session *session;
 
-       session = talloc_named(NULL, sizeof(*session), "smbcli_session");
+       session = talloc_p(transport, struct smbcli_session);
        if (!session) {
                return NULL;
        }
index 654d8ee61be7b21552f76ff7fccacb58880c8c80..566367233379fbb7953867718e64c08b2ef96e75 100644 (file)
@@ -29,7 +29,7 @@ struct smbcli_socket *smbcli_sock_init(void)
 {
        struct smbcli_socket *sock;
 
-       sock = talloc_named(NULL, sizeof(*sock), "smbcli_socket");
+       sock = talloc_p(NULL, struct smbcli_socket);
        if (!sock) {
                return NULL;
        }
index 85d5337da7abc297081793d22262167e0eaed059..c0d84179d6c15a20d7cd92effc8677e5ecc13036 100644 (file)
@@ -49,7 +49,7 @@ struct smbcli_transport *smbcli_transport_init(struct smbcli_socket *sock)
        struct smbcli_transport *transport;
        struct fd_event fde;
 
-       transport = talloc_named(NULL, sizeof(*transport), "smbcli_transport");
+       transport = talloc_p(sock, struct smbcli_transport);
        if (!transport) return NULL;
 
        ZERO_STRUCTP(transport);
index 03a49708b3bc489ebc7ad0baea67a2efd7fa06ef..c383eef768a084daa3cd2f9791ad4299bb0b4b98 100644 (file)
@@ -34,7 +34,7 @@ struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session)
 {
        struct smbcli_tree *tree;
 
-       tree = talloc_named(NULL, sizeof(*tree), "smbcli_tree");
+       tree = talloc_p(session, struct smbcli_tree);
        if (!tree) {
                return NULL;
        }
index 1ff36d0a8dc96956e45c2863868732bf362900a0..a94e79662846bd4e523653a31836cf5840bd09c7 100644 (file)
@@ -62,7 +62,7 @@ struct smbcli_request *smbcli_request_setup_nonsmb(struct smbcli_transport *tran
 {
        struct smbcli_request *req;
 
-       req = talloc_named(NULL, sizeof(struct smbcli_request), "smcli_request");
+       req = talloc_p(transport, struct smbcli_request);
        if (!req) {
                return NULL;
        }
index 9bd060c639eae3dd1728f05a4adb9abe96dda656..8705317b2a4338a20f8d2385facbf0dba51a3ebc 100644 (file)
@@ -59,7 +59,7 @@ static NTSTATUS pvfs_connect(struct smbsrv_request *req, const char *sharename,
 
        DEBUG(0,("WARNING: the posix vfs handler is incomplete - you probably want \"ntvfs handler = simple\"\n"));
 
-       pvfs = talloc_named(tcon, sizeof(struct pvfs_state), "pvfs_connect(%s)", sharename);
+       pvfs = talloc_p(tcon, struct pvfs_state);
        if (pvfs == NULL) {
                return NT_STATUS_NO_MEMORY;
        }
index 194c6d24cc1b275f347771e4e45be674214221ac..a587278b8e9b346e0f59a18e254c338e3674ddc3 100644 (file)
@@ -97,6 +97,10 @@ static void standard_terminate_connection(struct server_connection *conn, const
                talloc_free(conn->service->srv_ctx);
        }
 
+       /* this init_iconv() has the effect of freeing the iconv context memory,
+          which makes leak checking easier */
+       init_iconv();
+
        /* terminate this process */
        exit(0);
 }