summaryrefslogtreecommitdiff
path: root/source4/nbt_server/wins
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-12-28 04:55:53 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:47:53 -0500
commit1984ba6ee98d1f0d1a9c497ecdb9c361a062f769 (patch)
treede51fe7228f47dab83b20f7eb67e435668045d23 /source4/nbt_server/wins
parentb1c80c3cfab83bad414b30ca9a7e90a6073152df (diff)
downloadsamba-1984ba6ee98d1f0d1a9c497ecdb9c361a062f769.tar.gz
samba-1984ba6ee98d1f0d1a9c497ecdb9c361a062f769.tar.bz2
samba-1984ba6ee98d1f0d1a9c497ecdb9c361a062f769.zip
r12535: - simplify string list handling in a couple of places using str_list_add()
- don't reply with 127.0.0.1 in NBT or WINS name queries unless the query came in on the loopback interface. Otherwise clients can end up talking to themselves, which is not very productive :-) (This used to be commit df00f8b3428c6d1254e66275c90ae4025cb52c47)
Diffstat (limited to 'source4/nbt_server/wins')
-rw-r--r--source4/nbt_server/wins/winsdb.c11
-rw-r--r--source4/nbt_server/wins/winsserver.c8
2 files changed, 11 insertions, 8 deletions
diff --git a/source4/nbt_server/wins/winsdb.c b/source4/nbt_server/wins/winsdb.c
index 4cdcd592fc..a037f9cc49 100644
--- a/source4/nbt_server/wins/winsdb.c
+++ b/source4/nbt_server/wins/winsdb.c
@@ -350,21 +350,16 @@ size_t winsdb_addr_list_length(struct winsdb_addr **addresses)
const char **winsdb_addr_string_list(TALLOC_CTX *mem_ctx, struct winsdb_addr **addresses)
{
size_t len = winsdb_addr_list_length(addresses);
- const char **str_list;
+ const char **str_list=NULL;
size_t i;
- str_list = talloc_array(mem_ctx, const char *, len + 1);
- if (!str_list) return NULL;
-
for (i=0; i < len; i++) {
- str_list[i] = talloc_strdup(str_list, addresses[i]->address);
+ str_list = str_list_add(str_list, addresses[i]->address);
if (!str_list[i]) {
- talloc_free(str_list);
return NULL;
}
}
-
- str_list[len] = NULL;
+ talloc_steal(mem_ctx, str_list);
return str_list;
}
diff --git a/source4/nbt_server/wins/winsserver.c b/source4/nbt_server/wins/winsserver.c
index 78bf0bd141..44842c7542 100644
--- a/source4/nbt_server/wins/winsserver.c
+++ b/source4/nbt_server/wins/winsserver.c
@@ -370,6 +370,14 @@ static void nbtd_winsserver_query(struct nbt_name_socket *nbtsock,
if (!addresses) {
goto notfound;
}
+
+ /* if the query didn't come from loopback, then never give out
+ loopback in the reply, as loopback means something
+ different for the recipient than for us */
+ if (strcmp(src->addr, "127.0.0.1") != 0) {
+ str_list_remove(addresses, "127.0.0.1");
+ }
+
found:
nbtd_name_query_reply(nbtsock, packet, src, name,
0, nb_flags, addresses);