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 | |
parent | 0201b2fa9f31d8c9a75f3057f91b3f720f62292c (diff) | |
download | samba-9457b7ea2214aaa3a466e5dbc2daa0b931975073.tar.gz samba-9457b7ea2214aaa3a466e5dbc2daa0b931975073.tar.bz2 samba-9457b7ea2214aaa3a466e5dbc2daa0b931975073.zip |
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')
-rw-r--r-- | source4/libcli/config.mk | 2 | ||||
-rw-r--r-- | source4/libcli/resolve/resolve.c | 13 |
2 files changed, 12 insertions, 3 deletions
diff --git a/source4/libcli/config.mk b/source4/libcli/config.mk index 716e23b60d..246abd414a 100644 --- a/source4/libcli/config.mk +++ b/source4/libcli/config.mk @@ -65,7 +65,7 @@ LIBCLI_WREPL_OBJ_FILES = $(libclisrcdir)/wrepl/winsrepl.o $(eval $(call proto_header_template,$(libclisrcdir)/wrepl/winsrepl_proto.h,$(LIBCLI_WREPL_OBJ_FILES:.o=.c))) [SUBSYSTEM::LIBCLI_RESOLVE] -PUBLIC_DEPENDENCIES = NDR_NBT +PUBLIC_DEPENDENCIES = NDR_NBT LIBTSOCKET LIBCLI_RESOLVE_OBJ_FILES = $(libclisrcdir)/resolve/resolve.o diff --git a/source4/libcli/resolve/resolve.c b/source4/libcli/resolve/resolve.c index 0ad3a75e89..77f7f4f46b 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; |