summaryrefslogtreecommitdiff
path: root/source4/nbt_server/interfaces.c
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/interfaces.c
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/interfaces.c')
-rw-r--r--source4/nbt_server/interfaces.c35
1 files changed, 12 insertions, 23 deletions
diff --git a/source4/nbt_server/interfaces.c b/source4/nbt_server/interfaces.c
index f2ccc1c424..f607c070d8 100644
--- a/source4/nbt_server/interfaces.c
+++ b/source4/nbt_server/interfaces.c
@@ -251,43 +251,32 @@ const char **nbtd_address_list(struct nbtd_interface *iface, TALLOC_CTX *mem_ctx
struct nbtd_server *nbtsrv = iface->nbtsrv;
const char **ret = NULL;
struct nbtd_interface *iface2;
- int count = 0;
if (iface->ip_address) {
- ret = talloc_array(mem_ctx, const char *, 2);
- if (ret == NULL) goto failed;
-
- ret[0] = talloc_strdup(ret, iface->ip_address);
- if (ret[0] == NULL) goto failed;
- ret[1] = NULL;
-
- count = 1;
+ ret = str_list_add(ret, iface->ip_address);
}
for (iface2=nbtsrv->interfaces;iface2;iface2=iface2->next) {
- const char **ret2;
-
if (iface->ip_address &&
strcmp(iface2->ip_address, iface->ip_address) == 0) {
continue;
}
- ret2 = talloc_realloc(mem_ctx, ret, const char *, count+2);
- if (ret2 == NULL) goto failed;
- ret = ret2;
- ret[count] = talloc_strdup(ret, iface2->ip_address);
- if (ret[count] == NULL) goto failed;
- count++;
+ ret = str_list_add(ret, iface2->ip_address);
}
- if (ret == NULL) goto failed;
+ talloc_steal(mem_ctx, ret);
- ret[count] = NULL;
- return ret;
+ /* 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 (ret != NULL &&
+ iface->ip_address != NULL &&
+ strcmp(iface->ip_address, "127.0.0.1") != 0) {
+ str_list_remove(ret, "127.0.0.1");
+ }
-failed:
- talloc_free(ret);
- return NULL;
+ return ret;
}