diff options
author | Andrew Bartlett <abartlet@samba.org> | 2010-03-10 15:56:13 +1100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2010-03-11 11:27:47 +1100 |
commit | 9457b7ea2214aaa3a466e5dbc2daa0b931975073 (patch) | |
tree | b538507232c9ade7ba6bc8625d0a997d66fa0177 /source4/libcli/resolve | |
parent | 0201b2fa9f31d8c9a75f3057f91b3f720f62292c (diff) | |
download | samba-9457b7ea2214aaa3a466e5dbc2daa0b931975073.tar.gz |
s4:libcli/resolve Use a more robust way to return the string address
By going via these tevent functions, we avoid needing to dereference
the struct socket_address, which may contain a 'struct sockaddr' or
strings. The new dns_host_file resolver returns in the form of a
struct sockaddr.
Andrew Bartlett
Diffstat (limited to 'source4/libcli/resolve')
-rw-r--r-- | source4/libcli/resolve/resolve.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/source4/libcli/resolve/resolve.c b/source4/libcli/resolve/resolve.c index 0ad3a75e893..77f7f4f46bd 100644 --- a/source4/libcli/resolve/resolve.c +++ b/source4/libcli/resolve/resolve.c @@ -27,6 +27,7 @@ #include "system/network.h" #include "lib/socket/socket.h" #include "../lib/util/dlinklist.h" +#include "lib/tsocket/tsocket.h" struct resolve_state { struct resolve_context *ctx; @@ -145,7 +146,7 @@ struct composite_context *resolve_name_all_send(struct resolve_context *ctx, struct composite_context *c; struct resolve_state *state; - if (ctx == NULL || event_ctx == NULL) { + if (event_ctx == NULL) { return NULL; } @@ -239,8 +240,16 @@ NTSTATUS resolve_name_recv(struct composite_context *c, status = resolve_name_all_recv(c, mem_ctx, &addrs, NULL); if (NT_STATUS_IS_OK(status)) { - *reply_addr = talloc_steal(mem_ctx, addrs[0]->addr); + struct tsocket_address *t_addr = socket_address_to_tsocket_address(addrs, addrs[0]); + if (!t_addr) { + return NT_STATUS_NO_MEMORY; + } + + *reply_addr = tsocket_address_inet_addr_string(t_addr, mem_ctx); talloc_free(addrs); + if (!*reply_addr) { + return NT_STATUS_NO_MEMORY; + } } return status; |