1
0
mirror of https://github.com/samba-team/samba.git synced 2025-09-09 01:44:21 +03:00

libsmb: Use talloc_realloc() correctly in resolve_hosts()

On realloc failure the old value is still around

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Volker Lendecke
2020-09-22 13:52:57 +02:00
committed by Jeremy Allison
parent a357282153
commit c6a11d8dcd

View File

@@ -2819,6 +2819,7 @@ static NTSTATUS resolve_hosts(TALLOC_CTX *mem_ctx,
for (res = ailist; res; res = res->ai_next) { for (res = ailist; res; res = res->ai_next) {
struct sockaddr_storage ss = {0}; struct sockaddr_storage ss = {0};
struct sockaddr_storage *tmp = NULL;
if ((res->ai_addr == NULL) || if ((res->ai_addr == NULL) ||
(res->ai_addrlen == 0) || (res->ai_addrlen == 0) ||
@@ -2839,14 +2840,15 @@ static NTSTATUS resolve_hosts(TALLOC_CTX *mem_ctx,
} }
ret_count += 1; ret_count += 1;
iplist = talloc_realloc( tmp = talloc_realloc(
mem_ctx, iplist, struct sockaddr_storage, mem_ctx, iplist, struct sockaddr_storage,
ret_count); ret_count);
if (iplist == NULL) { if (tmp == NULL) {
DEBUG(3,("resolve_hosts: malloc fail !\n")); DEBUG(3,("resolve_hosts: malloc fail !\n"));
freeaddrinfo(ailist); freeaddrinfo(ailist);
return NT_STATUS_NO_MEMORY; return NT_STATUS_NO_MEMORY;
} }
iplist = tmp;
iplist[i] = ss; iplist[i] = ss;
i++; i++;
} }