svn commit: samba r12535 - in branches/SAMBA_4_0/source/nbt_server:
. wins
tridge at samba.org
tridge at samba.org
Wed Dec 28 04:55:54 GMT 2005
Author: tridge
Date: 2005-12-28 04:55:53 +0000 (Wed, 28 Dec 2005)
New Revision: 12535
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=12535
Log:
- 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 :-)
Modified:
branches/SAMBA_4_0/source/nbt_server/interfaces.c
branches/SAMBA_4_0/source/nbt_server/wins/winsdb.c
branches/SAMBA_4_0/source/nbt_server/wins/winsserver.c
Changeset:
Modified: branches/SAMBA_4_0/source/nbt_server/interfaces.c
===================================================================
--- branches/SAMBA_4_0/source/nbt_server/interfaces.c 2005-12-28 04:14:58 UTC (rev 12534)
+++ branches/SAMBA_4_0/source/nbt_server/interfaces.c 2005-12-28 04:55:53 UTC (rev 12535)
@@ -251,43 +251,32 @@
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;
}
Modified: branches/SAMBA_4_0/source/nbt_server/wins/winsdb.c
===================================================================
--- branches/SAMBA_4_0/source/nbt_server/wins/winsdb.c 2005-12-28 04:14:58 UTC (rev 12534)
+++ branches/SAMBA_4_0/source/nbt_server/wins/winsdb.c 2005-12-28 04:55:53 UTC (rev 12535)
@@ -350,21 +350,16 @@
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;
}
Modified: branches/SAMBA_4_0/source/nbt_server/wins/winsserver.c
===================================================================
--- branches/SAMBA_4_0/source/nbt_server/wins/winsserver.c 2005-12-28 04:14:58 UTC (rev 12534)
+++ branches/SAMBA_4_0/source/nbt_server/wins/winsserver.c 2005-12-28 04:55:53 UTC (rev 12535)
@@ -370,6 +370,14 @@
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);
More information about the samba-cvs
mailing list