From: Joseph Sutton Date: Mon, 13 Feb 2023 01:58:23 +0000 (+1300) Subject: libndr: Handle allocation failure X-Git-Tag: talloc-2.4.1~942 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a1e64e57378b90e8fdc5fbd4ea0d090af5ee0405;p=thirdparty%2Fsamba.git libndr: Handle allocation failure If a talloc function returns NULL, indicating failure, the failure could be masked by the next talloc call allocating on the NULL context. Signed-off-by: Joseph Sutton Reviewed-by: Andreas Schneider --- diff --git a/librpc/ndr/ndr_basic.c b/librpc/ndr/ndr_basic.c index e239cfb27d9..39aa3690cbe 100644 --- a/librpc/ndr/ndr_basic.c +++ b/librpc/ndr/ndr_basic.c @@ -1016,12 +1016,15 @@ _PUBLIC_ enum ndr_err_code ndr_pull_ipv6address(struct ndr_pull *ndr, int ndr_fl uint8_t addr[IPV6_BYTES]; char *addr_str = talloc_strdup(ndr->current_mem_ctx, ""); int i; + NDR_ERR_HAVE_NO_MEMORY(addr_str); NDR_CHECK(ndr_pull_array_uint8(ndr, ndr_flags, addr, IPV6_BYTES)); for (i = 0; i < IPV6_BYTES; ++i) { addr_str = talloc_asprintf_append(addr_str, "%02x", addr[i]); + NDR_ERR_HAVE_NO_MEMORY(addr_str); /* We need a ':' every second byte but the last one */ if (i%2 == 1 && i != (IPV6_BYTES - 1)) { addr_str = talloc_strdup_append(addr_str, ":"); + NDR_ERR_HAVE_NO_MEMORY(addr_str); } } *address = addr_str;