summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2011-12-13 17:22:34 +1100
committerAndrew Bartlett <abartlet@samba.org>2011-12-14 01:16:37 +0100
commit079d1572c2e9c3a349ad63514034673d07b1a557 (patch)
tree2f7c9924dd344968fe645606559ec2c175727440
parent8a4b5cdfea7b2370b9d700e7dbdaa8143cfc972c (diff)
downloadsamba-079d1572c2e9c3a349ad63514034673d07b1a557.tar.gz
samba-079d1572c2e9c3a349ad63514034673d07b1a557.tar.bz2
samba-079d1572c2e9c3a349ad63514034673d07b1a557.zip
s4-resolv: fix dns_ex so as to fail correctly when a name does not exist
Without this, netbios name lookups do not work, as we never fall back to them. This caused segfaults from e38d97e0424f7e5b21c8b7ac0b1f1bac33f19d69 to 251209bd6f6e66ca9bcf28cd652d85d1cd729fdc and then name lookup failure or timeouts until this patch. Andrew Bartlett Autobuild-User: Andrew Bartlett <abartlet@samba.org> Autobuild-Date: Wed Dec 14 01:16:37 CET 2011 on sn-devel-104
-rw-r--r--source4/libcli/resolve/dns_ex.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/source4/libcli/resolve/dns_ex.c b/source4/libcli/resolve/dns_ex.c
index 9467521394..4f46235a9f 100644
--- a/source4/libcli/resolve/dns_ex.c
+++ b/source4/libcli/resolve/dns_ex.c
@@ -393,6 +393,12 @@ static void run_child_dns_lookup(struct dns_ex_state *state, int fd)
c = get_a_aaaa_records(state, state->name.name, state->port);
}
+ /* This line in critical - if we return without writing to the
+ * pipe, this is the signal that the name did not exist */
+ if (c.count == 0) {
+ goto done;
+ }
+
addrs = talloc_strdup(state, "");
if (!addrs) {
goto done;
@@ -521,6 +527,9 @@ static void pipe_handler(struct tevent_context *ev, struct tevent_fd *fde,
}
if (ret <= 0) {
+ /* The check for ret == 0 here is important, if the
+ * name does not exist, then no bytes are written to
+ * the pipe */
DEBUG(3,("dns child failed to find name '%s' of type %s\n",
state->name.name, (state->flags & RESOLVE_NAME_FLAG_DNS_SRV)?"SRV":"A"));
composite_error(c, NT_STATUS_OBJECT_NAME_NOT_FOUND);