summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;