summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2004-10-26 14:22:37 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:53:03 -0500
commit0e1de2d773c274ae2981a69a05c61919b52143ee (patch)
treef42cff08f27d1dfa424e9c2c43e5dae076d0e98c
parente497f001bbd669db9e6d6140dc6ccf005dd2d99d (diff)
downloadsamba-0e1de2d773c274ae2981a69a05c61919b52143ee.tar.gz
samba-0e1de2d773c274ae2981a69a05c61919b52143ee.tar.bz2
samba-0e1de2d773c274ae2981a69a05c61919b52143ee.zip
r3264: fix lmhosts lookup so that we don't say we found something when we really didn't
(This used to be commit c7036f824627dc555185a52ed95d3e0132babcd8)
-rw-r--r--source3/libsmb/namequery.c53
1 files changed, 29 insertions, 24 deletions
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index 2e6842088a..cdbc7f758a 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -847,6 +847,7 @@ static BOOL resolve_lmhosts(const char *name, int name_type,
pstring lmhost_name;
int name_type2;
struct in_addr return_ip;
+ BOOL result = False;
*return_iplist = NULL;
*return_count = 0;
@@ -854,38 +855,42 @@ static BOOL resolve_lmhosts(const char *name, int name_type,
DEBUG(3,("resolve_lmhosts: Attempting lmhosts lookup for name %s<0x%x>\n", name, name_type));
fp = startlmhosts(dyn_LMHOSTSFILE);
- if(fp) {
- while (getlmhostsent(fp, lmhost_name, &name_type2,
- &return_ip)) {
- if (!strequal(name, lmhost_name))
- continue;
+ if ( fp == NULL )
+ return False;
- if ((name_type2 != -1) && (name_type != name_type2))
- continue;
+ while (getlmhostsent(fp, lmhost_name, &name_type2, &return_ip))
+ {
- *return_iplist = (struct ip_service *)
- realloc((*return_iplist),
- sizeof(struct ip_service) *
- ((*return_count)+1));
+ if (!strequal(name, lmhost_name))
+ continue;
- if ((*return_iplist) == NULL) {
- DEBUG(3,("resolve_lmhosts: malloc fail !\n"));
- return False;
- }
+ if ((name_type2 != -1) && (name_type != name_type2))
+ continue;
- (*return_iplist)[*return_count].ip = return_ip;
- (*return_iplist)[*return_count].port = PORT_NONE;
- *return_count += 1;
+ *return_iplist = (struct ip_service *)realloc((*return_iplist),
+ sizeof(struct ip_service) * ((*return_count)+1));
- /* Multiple names only for DC lookup */
- if (name_type != 0x1c)
- break;
+ if ((*return_iplist) == NULL) {
+ DEBUG(3,("resolve_lmhosts: malloc fail !\n"));
+ return False;
}
- endlmhosts(fp);
- return True;
+
+ (*return_iplist)[*return_count].ip = return_ip;
+ (*return_iplist)[*return_count].port = PORT_NONE;
+ *return_count += 1;
+
+ /* we found something */
+ result = True;
+
+ /* Multiple names only for DC lookup */
+ if (name_type != 0x1c)
+ break;
}
- return False;
+
+ endlmhosts(fp);
+
+ return result;
}