diff options
author | Andrew Tridgell <tridge@samba.org> | 2002-01-11 00:23:29 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2002-01-11 00:23:29 +0000 |
commit | 12021a8de6a1dc2e43cc62f094a57c57283dfaf4 (patch) | |
tree | ef0f8566a69856fed82c49bcc35cd996d0fe1007 /source/libsmb | |
parent | a4af65b9b93671f13f277d49279a85042a8fd1d5 (diff) | |
download | samba-12021a8de6a1dc2e43cc62f094a57c57283dfaf4.tar.gz samba-12021a8de6a1dc2e43cc62f094a57c57283dfaf4.tar.xz samba-12021a8de6a1dc2e43cc62f094a57c57283dfaf4.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
Diffstat (limited to 'source/libsmb')
-rw-r--r-- | source/libsmb/namequery.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/source/libsmb/namequery.c b/source/libsmb/namequery.c index 6bf34c730cc..d7e0af11df9 100644 --- a/source/libsmb/namequery.c +++ b/source/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; |