From 188bfbc19230c5451059375cb648d06362ac9395 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 21 Jan 2008 15:24:23 +0100 Subject: Add a check for talloc failure. - Pointed out by Volker. Michael (This used to be commit bdc49b07cc6de36c9319254a131858c9a7f9dd53) --- source3/libnet/libnet_conf.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index d20e10b141..152148300e 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -48,6 +48,10 @@ static WERROR libnet_conf_add_string_to_array(TALLOC_CTX *mem_ctx, } new_array[count] = talloc_strdup(new_array, string); + if (new_array[count] == NULL) { + TALLOC_FREE(new_array); + return WERR_NOMEM; + } *array = new_array; -- cgit From 7f2e253efbf5ce9a7195efcd5fee778b219faebb Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 21 Jan 2008 15:28:04 +0100 Subject: Use talloc_stackframe() for temporary contexts throughout libnet_conf.c Michael (This used to be commit 4d734106b70b9b6029b537fe11f8b3c1aebd42cf) --- source3/libnet/libnet_conf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 152148300e..ec05fa7c16 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -195,7 +195,7 @@ static WERROR libnet_conf_reg_create_service_key(TALLOC_CTX *mem_ctx, /* create a new talloc ctx for creation. it will hold * the intermediate parent key (SMBCONF) for creation * and will be destroyed when leaving this function... */ - if (!(create_ctx = talloc_new(mem_ctx))) { + if (!(create_ctx = talloc_stackframe())) { werr = WERR_NOMEM; goto done; } @@ -361,7 +361,7 @@ static WERROR libnet_conf_reg_get_values(TALLOC_CTX *mem_ctx, goto done; } - tmp_ctx = talloc_new(mem_ctx); + tmp_ctx = talloc_stackframe(); if (tmp_ctx == NULL) { werr = WERR_NOMEM; goto done; @@ -544,7 +544,7 @@ WERROR libnet_conf_get_config(TALLOC_CTX *mem_ctx, goto done; } - tmp_ctx = talloc_new(mem_ctx); + tmp_ctx = talloc_stackframe(); if (tmp_ctx == NULL) { werr = WERR_NOMEM; goto done; @@ -619,7 +619,7 @@ WERROR libnet_conf_get_share_names(TALLOC_CTX *mem_ctx, goto done; } - tmp_ctx = talloc_new(mem_ctx); + tmp_ctx = talloc_stackframe(); if (tmp_ctx == NULL) { werr = WERR_NOMEM; goto done; -- cgit From c5c38d622754c5b06716cbae41a27af711d22bcf Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 21 Jan 2008 15:31:57 +0100 Subject: Fix formatting of multi_sz registry values. Don't print only the last component. Michael (This used to be commit 654e96208ec847e32797cbd2442ef9e73c014567) --- source3/libnet/libnet_conf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index ec05fa7c16..fc797bbeb9 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -320,8 +320,12 @@ static char *libnet_conf_format_registry_value(TALLOC_CTX *mem_ctx, case REG_MULTI_SZ: { uint32 j; for (j = 0; j < value->v.multi_sz.num_strings; j++) { - result = talloc_asprintf(mem_ctx, "\"%s\" ", + result = talloc_asprintf(mem_ctx, "%s \"%s\" ", + result, value->v.multi_sz.strings[j]); + if (result == NULL) { + break; + } } break; } -- cgit From feb77c978bede01156ae1eb17c73842c7a27cda5 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 21 Jan 2008 15:35:09 +0100 Subject: Add another check for talloc failure to libnet_conf Michael (This used to be commit 196e4ce8c5dd5aab518aaa7d170eb1fb5d66bcd1) --- source3/libnet/libnet_conf.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index fc797bbeb9..4d998acad8 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -138,6 +138,10 @@ static WERROR libnet_conf_reg_open_service_key(TALLOC_CTX *mem_ctx, } path = talloc_asprintf(mem_ctx, "%s\\%s", KEY_SMBCONF, servicename); + if (path == NULL) { + werr = WERR_NOMEM; + goto done; + } werr = libnet_conf_reg_open_path(mem_ctx, ctx, path, desired_access, key); -- cgit