s4:rpc_server/dnsserver: Zero-initialise pointers
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Tue, 10 Jan 2023 00:06:31 +0000 (13:06 +1300)
committerJeremy Allison <jra@samba.org>
Tue, 10 Jan 2023 20:22:32 +0000 (20:22 +0000)
Ensuring pointers are always initialised simplifies the code and avoids
compilation errors with FORTIFY_SOURCE=2.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
source4/rpc_server/dnsserver/dcerpc_dnsserver.c

index ea4d86d3c24e3a3b47149ba1012b5b98a014dd73..8a8ba4b4f22c2ce392f4c5722b48cbd5ae72f80d 100644 (file)
@@ -200,10 +200,10 @@ static WERROR dnsserver_query_server(struct dnsserver_state *dsstate,
 {
        uint8_t is_integer, is_addresses, is_string, is_wstring, is_stringlist;
        uint32_t answer_integer;
-       struct IP4_ARRAY *answer_iparray;
-       struct DNS_ADDR_ARRAY *answer_addrarray;
-       char *answer_string;
-       struct DNS_RPC_UTF8_STRING_LIST *answer_stringlist;
+       struct IP4_ARRAY *answer_iparray = NULL;
+       struct DNS_ADDR_ARRAY *answer_addrarray = NULL;
+       char *answer_string = NULL;
+       struct DNS_RPC_UTF8_STRING_LIST *answer_stringlist = NULL;
        struct dnsserver_serverinfo *serverinfo;
 
        serverinfo = dsstate->serverinfo;
@@ -729,18 +729,8 @@ static WERROR dnsserver_query_server(struct dnsserver_state *dsstate,
                }
                is_addresses = 1;
        } else if (strcasecmp(operation, "BreakOnReceiveFrom") == 0) {
-               if (client_version == DNS_CLIENT_VERSION_LONGHORN) {
-                       answer_addrarray = NULL;
-               } else {
-                       answer_iparray = NULL;
-               }
                is_addresses = 1;
        } else if (strcasecmp(operation, "BreakOnUpdateFrom") == 0) {
-               if (client_version == DNS_CLIENT_VERSION_LONGHORN) {
-                       answer_addrarray = NULL;
-               } else {
-                       answer_iparray = NULL;
-               }
                is_addresses = 1;
        } else if (strcasecmp(operation, "LogIPFilterList") == 0) {
                if (client_version == DNS_CLIENT_VERSION_LONGHORN) {
@@ -780,13 +770,10 @@ static WERROR dnsserver_query_server(struct dnsserver_state *dsstate,
                answer_string = talloc_strdup(mem_ctx, serverinfo->pwszLogFilePath);
                is_wstring = 1;
        } else if (strcasecmp(operation, "ServerLevelPluginDll") == 0) {
-               answer_string = NULL;
                is_wstring = 1;
        } else if (strcasecmp(operation, "DsBackgroundPauseName") == 0) {
-               answer_string = NULL;
                is_string = 1;
        } else if (strcasecmp(operation, "DsNotRoundRobinTypes") == 0) {
-               answer_string = NULL;
                is_string = 1;
        }
 
@@ -803,10 +790,8 @@ static WERROR dnsserver_query_server(struct dnsserver_state *dsstate,
        is_stringlist = 0;
 
        if (strcasecmp(operation, "GlobalQueryBlockList") == 0) {
-               answer_stringlist = NULL;
                is_stringlist = 1;
        } else if (strcasecmp(operation, "SocketPoolExcludedPortRanges") == 0) {
-               answer_stringlist = NULL;
                is_stringlist = 1;
        }
 
@@ -831,9 +816,9 @@ static WERROR dnsserver_query_zone(struct dnsserver_state *dsstate,
 {
        uint8_t is_integer, is_addresses, is_string;
        uint32_t answer_integer = 0;
-       struct IP4_ARRAY *answer_iparray;
-       struct DNS_ADDR_ARRAY *answer_addrarray;
-       char *answer_string;
+       struct IP4_ARRAY *answer_iparray = NULL;
+       struct DNS_ADDR_ARRAY *answer_addrarray = NULL;
+       char *answer_string = NULL;
        struct dnsserver_zoneinfo *zoneinfo;
 
        zoneinfo = z->zoneinfo;
@@ -1021,11 +1006,6 @@ static WERROR dnsserver_query_zone(struct dnsserver_state *dsstate,
        is_addresses = 0;
 
        if (strcasecmp(operation, "AllowNSRecordsAutoCreation") == 0) {
-               if (client_version == DNS_CLIENT_VERSION_LONGHORN) {
-                       answer_addrarray = NULL;
-               } else {
-                       answer_iparray = NULL;
-               }
                is_addresses = 1;
        } else if (strcasecmp(operation, "ScavengeServers") == 0) {
                if (client_version == DNS_CLIENT_VERSION_LONGHORN) {
@@ -1084,7 +1064,6 @@ static WERROR dnsserver_query_zone(struct dnsserver_state *dsstate,
                answer_string = talloc_strdup(mem_ctx, z->partition->pszDpFqdn);
                is_string = 1;
        } else if (strcasecmp(operation, "BreakOnNameUpdate") == 0) {
-               answer_string = NULL;
                is_string = 1;
        }