summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2002-01-11 00:23:29 +0000
committerAndrew Tridgell <tridge@samba.org>2002-01-11 00:23:29 +0000
commit3fb5e2867c947de65d0c75a2ea1b9be46bbc5346 (patch)
tree4b4f80754c370a70780cea16c38f423538bed14c
parent85e06cebc018ce29cfd4788af857a376b13929e9 (diff)
downloadsamba-3fb5e2867c947de65d0c75a2ea1b9be46bbc5346.tar.gz
samba-3fb5e2867c947de65d0c75a2ea1b9be46bbc5346.tar.bz2
samba-3fb5e2867c947de65d0c75a2ea1b9be46bbc5346.zip
make sure resolve_name() only returns valid IP addresses
this is actually a workaround for old broken nmbd daemons, especially from Samba 2.0 (This used to be commit 12021a8de6a1dc2e43cc62f094a57c57283dfaf4)
-rw-r--r--source3/libsmb/namequery.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index 6bf34c730c..d7e0af11df 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -954,10 +954,19 @@ BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type)
struct in_addr *ip_list = NULL;
int count = 0;
- if(internal_resolve_name(name, name_type, &ip_list, &count)) {
- *return_ip = ip_list[0];
- SAFE_FREE(ip_list);
- return True;
+ if (internal_resolve_name(name, name_type, &ip_list, &count)) {
+ int i;
+ /* only return valid addresses for TCP connections */
+ for (i=0; i<count; i++) {
+ char *ip_str = inet_ntoa(ip_list[i]);
+ if (ip_str &&
+ strcmp(ip_str, "255.255.255.255") != 0 &&
+ strcmp(ip_str, "0.0.0.0") != 0) {
+ *return_ip = ip_list[i];
+ SAFE_FREE(ip_list);
+ return True;
+ }
+ }
}
SAFE_FREE(ip_list);
return False;