From 13acac25cb48ec39a0b35abb272de727f19bb236 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 2 Sep 2020 10:05:48 -0700 Subject: [PATCH] s3: libsmb: Cleanup - ensure we initialize all stack variables to 'safe' values when calling get_sorted_dc_list() that may not touch returns on error. Signed-off-by: Jeremy Allison Reviewed-by: Noel Power --- source3/libads/ldap.c | 7 ++++--- source3/libsmb/namequery_dc.c | 3 ++- source3/utils/net_lookup.c | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c index 2fc9b2009b6..1925220515e 100755 --- a/source3/libads/ldap.c +++ b/source3/libads/ldap.c @@ -383,8 +383,9 @@ static NTSTATUS cldap_ping_list(ADS_STRUCT *ads,const char *domain, static NTSTATUS resolve_and_ping_netbios(ADS_STRUCT *ads, const char *domain, const char *realm) { - int count, i; - struct ip_service *ip_list; + size_t i; + size_t count = 0; + struct ip_service *ip_list = NULL; NTSTATUS status; DEBUG(6, ("resolve_and_ping_netbios: (cldap) looking for domain '%s'\n", @@ -430,7 +431,7 @@ static NTSTATUS resolve_and_ping_netbios(ADS_STRUCT *ads, static NTSTATUS resolve_and_ping_dns(ADS_STRUCT *ads, const char *sitename, const char *realm) { - int count; + size_t count = 0; struct ip_service *ip_list = NULL; NTSTATUS status; diff --git a/source3/libsmb/namequery_dc.c b/source3/libsmb/namequery_dc.c index 77a7ce30e35..96b5f565773 100644 --- a/source3/libsmb/namequery_dc.c +++ b/source3/libsmb/namequery_dc.c @@ -165,8 +165,9 @@ static bool rpc_dc_name(const char *domain, struct sockaddr_storage *ss_out) { struct ip_service *ip_list = NULL; + size_t count = 0; struct sockaddr_storage dc_ss; - int count, i; + size_t i; NTSTATUS result; char addr[INET6_ADDRSTRLEN]; diff --git a/source3/utils/net_lookup.c b/source3/utils/net_lookup.c index 777ac38dee9..82dbdc45267 100644 --- a/source3/utils/net_lookup.c +++ b/source3/utils/net_lookup.c @@ -188,7 +188,8 @@ static int net_lookup_dc(struct net_context *c, int argc, const char **argv) char *pdc_str = NULL; const char *domain = NULL; char *sitename = NULL; - int count, i; + size_t count = 0; + size_t i; char addr[INET6_ADDRSTRLEN]; bool sec_ads = (lp_security() == SEC_ADS); -- 2.34.1