lib: dns: Clean up allocated structure on error exit.
[sfrench/samba-autobuild/.git] / lib / addns / dnsutils.c
index 37b862c7f0798121e8f71c10a39146074798b915..3eeb6ab9e21f7adf2b59899cb2c3274d6f77a9cd 100644 (file)
   License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
 
+#include "includes.h"
+#include "librpc/ndr/libndr.h"
+#include "librpc/gen_ndr/ndr_misc.h"
+
 #include "dns.h"
 #include <ctype.h>
 
+
 static DNS_ERROR LabelList( TALLOC_CTX *mem_ctx,
                            const char *name,
                            struct dns_domain_label **presult )
@@ -53,7 +58,7 @@ static DNS_ERROR LabelList( TALLOC_CTX *mem_ctx,
                return ERROR_DNS_INVALID_NAME;
        }
 
-       if (!(result = TALLOC_ZERO_P(mem_ctx, struct dns_domain_label))) {
+       if (!(result = talloc_zero(mem_ctx, struct dns_domain_label))) {
                return ERROR_DNS_NO_MEMORY;
        }
 
@@ -133,17 +138,10 @@ char *dns_generate_keyname( TALLOC_CTX *mem_ctx )
        char *result = NULL;
 #if defined(WITH_DNS_UPDATES)
 
-       uuid_t uuid;
-
-       /*
-        * uuid_unparse gives 36 bytes plus '\0'
-        */
-       if (!(result = TALLOC_ARRAY(mem_ctx, char, 37))) {
-               return NULL;
-       }
+       struct GUID guid;
 
-       uuid_generate( uuid );
-       uuid_unparse( uuid, result );
+       guid = GUID_random();
+       result = GUID_string(mem_ctx, &guid);
 
 #endif