1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-27 03:21:53 +03:00

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
This commit is contained in:
Rafal Szczesniak 2006-07-09 13:18:15 +00:00 committed by Gerald (Jerry) Carter
parent e597e9867f
commit 1bd5661258

View File

@ -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;