The branch, master has been updated
       via  e01d7d9 Replace NT_STATUS_HAVE_NO_MEMORY macro
       via  6d0b6e9 Minor cleanup of libnet_LookupName_recv
       via  14f83ff Zero libnet_LookupName out struct before using
      from  6ba2426 WHATSNEW: Add info for 'net ads keytab' and 'net ads 
setspn' changes

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


- Log -----------------------------------------------------------------
commit e01d7d9d0f76b5624bc10d94965fad8f22b4ea7b
Author: Swen Schillig <s...@vnet.ibm.com>
Date:   Thu Feb 1 09:39:02 2018 +0100

    Replace NT_STATUS_HAVE_NO_MEMORY macro
    
    Replaced NT_STATUS_HAVE_NO_MEMORY macro and fixed
    memory leaking error-path.
    
    Signed-off-by: Swen Schillig <s...@vnet.ibm.com>
    Reviewed-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Christof Schmitt <c...@samba.org>
    
    Autobuild-User(master): Christof Schmitt <c...@samba.org>
    Autobuild-Date(master): Sat Mar  3 00:00:34 CET 2018 on sn-devel-144

commit 6d0b6e937a55c55797f1d1136c3f75d27d6fa0d3
Author: Swen Schillig <s...@vnet.ibm.com>
Date:   Thu Feb 1 09:02:25 2018 +0100

    Minor cleanup of libnet_LookupName_recv
    
    Reduce indentation level and comply with 80 column rule.
    
    Signed-off-by: Swen Schillig <s...@vnet.ibm.com>
    Reviewed-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Christof Schmitt <c...@samba.org>

commit 14f83ff83589e8f43cbd47a4115c2e9afcf4d5cb
Author: Swen Schillig <s...@vnet.ibm.com>
Date:   Fri Jan 26 13:28:58 2018 +0100

    Zero libnet_LookupName out struct before using
    
    Zero libnet_LookupName out struct before setting results,
    preventing false result interpretation.
    
    Signed-off-by: Swen Schillig <s...@vnet.ibm.com>
    Reviewed-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Christof Schmitt <c...@samba.org>

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

Summary of changes:
 source4/libnet/libnet_lookup.c | 76 ++++++++++++++++++++++++------------------
 1 file changed, 44 insertions(+), 32 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/libnet/libnet_lookup.c b/source4/libnet/libnet_lookup.c
index bdb9995..63ce601 100644
--- a/source4/libnet/libnet_lookup.c
+++ b/source4/libnet/libnet_lookup.c
@@ -381,45 +381,57 @@ NTSTATUS libnet_LookupName_recv(struct composite_context 
*c, TALLOC_CTX *mem_ctx
                                struct libnet_LookupName *io)
 {
        NTSTATUS status;
-       struct lookup_name_state *s;
+       struct lookup_name_state *s = NULL;
+       struct lsa_RefDomainList *domains = NULL;
+       struct lsa_TransSidArray *sids = NULL;
 
        status = composite_wait(c);
+       ZERO_STRUCT(io->out);
 
-       if (NT_STATUS_IS_OK(status)) {
-               s = talloc_get_type(c->private_data, struct lookup_name_state);
-
-               io->out.rid = 0;
-               io->out.sid = NULL;
-               io->out.sidstr = NULL;
-
-               if (*s->lookup.out.count > 0) {
-                       struct lsa_RefDomainList *domains = 
*s->lookup.out.domains;
-                       struct lsa_TransSidArray *sids = s->lookup.out.sids;
-
-                       if (domains == NULL || sids == NULL) {
-                               status = NT_STATUS_UNSUCCESSFUL;
-                               io->out.error_string = talloc_asprintf(mem_ctx, 
"Error: %s", nt_errstr(status));
-                               goto done;
-                       }
-
-                       if (sids->count > 0) {
-                               io->out.rid        = sids->sids[0].rid;
-                               io->out.sid_type   = sids->sids[0].sid_type;
-                               if (domains->count > 0) {
-                                       io->out.sid = dom_sid_add_rid(mem_ctx, 
domains->domains[0].sid, io->out.rid);
-                                       NT_STATUS_HAVE_NO_MEMORY(io->out.sid);
-                                       io->out.sidstr = 
dom_sid_string(mem_ctx, io->out.sid);
-                                       
NT_STATUS_HAVE_NO_MEMORY(io->out.sidstr);
-                               }
-                       }
-               }
+       if (!NT_STATUS_IS_OK(status)) {
+               io->out.error_string = talloc_asprintf(mem_ctx, "Error: %s",
+                                                      nt_errstr(status));
+               goto done;
+       }
+
+       s = talloc_get_type(c->private_data, struct lookup_name_state);
+
+       if (*s->lookup.out.count == 0) {
+               goto success;
+       }
+
+       domains = *s->lookup.out.domains;
+       sids = s->lookup.out.sids;
 
-               io->out.error_string = talloc_strdup(mem_ctx, "Success");
+       if (domains == NULL || sids == NULL) {
+               status = NT_STATUS_UNSUCCESSFUL;
+               io->out.error_string = talloc_asprintf(mem_ctx, "Error: %s",
+                                                      nt_errstr(status));
+               goto done;
+       }
 
-       } else if (!NT_STATUS_IS_OK(status)) {
-               io->out.error_string = talloc_asprintf(mem_ctx, "Error: %s", 
nt_errstr(status));
+       if (sids->count == 0) {
+               goto success;
+       }
+
+       io->out.rid        = sids->sids[0].rid;
+       io->out.sid_type   = sids->sids[0].sid_type;
+       if (domains->count > 0) {
+               io->out.sid = dom_sid_add_rid(mem_ctx, domains->domains[0].sid,
+                                             io->out.rid);
+               if (io->out.sid == NULL) {
+                       status = NT_STATUS_NO_MEMORY;
+                       goto done;
+               }
+               io->out.sidstr = dom_sid_string(mem_ctx, io->out.sid);
+               if (io->out.sidstr == NULL) {
+                       status = NT_STATUS_NO_MEMORY;
+                       goto done;
+               }
        }
 
+success:
+       io->out.error_string = talloc_strdup(mem_ctx, "Success");
 done:
        talloc_free(c);
        return status;


-- 
Samba Shared Repository

Reply via email to