s4/dsdb/common: clang: Fix access results in null pointer deref.
authorNoel Power <noel.power@suse.com>
Mon, 8 Jul 2019 13:43:20 +0000 (13:43 +0000)
committerGary Lockyer <gary@samba.org>
Thu, 11 Jul 2019 04:08:13 +0000 (04:08 +0000)
Fixes:

source4/dsdb/common/util_trusts.c:2915:21: warning: Access to field 'sid' results in a dereference of a null pointer (loaded from field 'tdo') <--[clang]
        d->di.domain_sid = d->tdo->sid;
                           ^  ~~~
1 warning generated.

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
source4/dsdb/common/util_trusts.c

index d2183911470dafc1ee766fa233f733d8ca3765ea..b4571dca95700f04d5b46cc2e6006a2e6f1ddf58 100644 (file)
@@ -2912,6 +2912,14 @@ NTSTATUS dsdb_trust_routing_table_load(struct ldb_context *sam_ctx,
                return status;
        }
 
+       /*
+        * d->tdo should not be NULL of status above is 'NT_STATUS_OK'
+        * check is needed to satisfy clang static checker
+       */
+       if (d->tdo == NULL) {
+               TALLOC_FREE(frame);
+               return NT_STATUS_NO_MEMORY;
+       }
        d->di.domain_sid = d->tdo->sid;
        d->di.netbios_domain_name.string = d->tdo->netbios_name.string;
        d->di.dns_domain_name.string = d->tdo->domain_name.string;