From 1bd5661258dffc01afdb11da50f2da8f0b0b9046 Mon Sep 17 00:00:00 2001 From: Rafal Szczesniak Date: Sun, 9 Jul 2006 13:18:15 +0000 Subject: [PATCH] r16897: Don't pass allocated buffer for returned string as the lookup function allocates it using memory context. Also, give nicer output of the result of lookup performed. rafal --- source/torture/libnet/libnet_lookup.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/source/torture/libnet/libnet_lookup.c b/source/torture/libnet/libnet_lookup.c index 12f3863afb2..c8e25817fc2 100644 --- a/source/torture/libnet/libnet_lookup.c +++ b/source/torture/libnet/libnet_lookup.c @@ -43,8 +43,6 @@ BOOL torture_lookup(struct torture_context *torture) ctx = libnet_context_init(NULL); ctx->cred = cmdline_credentials; - address = talloc_array(ctx, const char, 16); - lookup.in.hostname = lp_parm_string(-1, "torture", "host"); if (lookup.in.hostname == NULL) { bindstr = lp_parm_string(-1, "torture", "binding"); @@ -56,7 +54,7 @@ BOOL torture_lookup(struct torture_context *torture) lookup.in.type = NBT_NAME_CLIENT; lookup.in.methods = NULL; - lookup.out.address = &address; + lookup.out.address = NULL; status = libnet_Lookup(ctx, mem_ctx, &lookup); @@ -68,6 +66,8 @@ BOOL torture_lookup(struct torture_context *torture) ret = True; + printf("Name [%s] found at adrress: %s.\n", lookup.in.hostname, *lookup.out.address); + done: talloc_free(mem_ctx); return ret; @@ -83,15 +83,12 @@ BOOL torture_lookup_host(struct torture_context *torture) struct libnet_Lookup lookup; struct dcerpc_binding *bind; const char *bindstr; - const char *address; mem_ctx = talloc_init("test_lookup_host"); ctx = libnet_context_init(NULL); ctx->cred = cmdline_credentials; - address = talloc_array(mem_ctx, const char, 16); - lookup.in.hostname = lp_parm_string(-1, "torture", "host"); if (lookup.in.hostname == NULL) { bindstr = lp_parm_string(-1, "torture", "binding"); @@ -102,7 +99,7 @@ BOOL torture_lookup_host(struct torture_context *torture) } lookup.in.methods = NULL; - lookup.out.address = &address; + lookup.out.address = NULL; status = libnet_LookupHost(ctx, mem_ctx, &lookup); @@ -114,6 +111,8 @@ BOOL torture_lookup_host(struct torture_context *torture) ret = True; + printf("Host [%s] found at adrress: %s.\n", lookup.in.hostname, *lookup.out.address); + done: talloc_free(mem_ctx); return ret;