From f912f5d872c346951347bb81116136dcc937ac96 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 17 Mar 1998 00:57:46 +0000 Subject: Fixes for the static data bugs & incorrect use of strtok that Andrew pointed out. Jeremy. (This used to be commit 734dde8d686827c387e17922fa6ac56af60780d9) --- source3/libsmb/namequery.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'source3/libsmb') diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index 6bf41b9f9e..7b8a01b28f 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -424,9 +424,11 @@ void endlmhosts(FILE *fp) BOOL resolve_name(char *name, struct in_addr *return_ip) { - char *p; int i; BOOL pure_address = True; + pstring name_resolve_list; + fstring tok; + char *ptr; if (strcmp(name,"0.0.0.0") == 0) { return_ip->s_addr = 0; @@ -447,8 +449,10 @@ BOOL resolve_name(char *name, struct in_addr *return_ip) return True; } - for (p=strtok(lp_name_resolve_order(),LIST_SEP); p; p = strtok(NULL,LIST_SEP)) { - if(strequal(p, "host") || strequal(p, "hosts")) { + pstrcpy(name_resolve_list, lp_name_resolve_order()); + ptr = name_resolve_list; + while (next_token(&ptr, tok, LIST_SEP)) { + if(strequal(tok, "host") || strequal(tok, "hosts")) { /* * "host" means do a localhost, or dns lookup. @@ -463,7 +467,7 @@ BOOL resolve_name(char *name, struct in_addr *return_ip) return True; } - } else if(strequal( p, "lmhosts")) { + } else if(strequal( tok, "lmhosts")) { /* * "lmhosts" means parse the local lmhosts file. @@ -486,7 +490,7 @@ BOOL resolve_name(char *name, struct in_addr *return_ip) endlmhosts(fp); } - } else if(strequal( p, "wins")) { + } else if(strequal( tok, "wins")) { int sock; @@ -524,7 +528,7 @@ BOOL resolve_name(char *name, struct in_addr *return_ip) } else { DEBUG(3,("resolve_name: WINS server resolution selected and no WINS server present.\n")); } - } else if(strequal( p, "bcast")) { + } else if(strequal( tok, "bcast")) { int sock; @@ -560,7 +564,7 @@ BOOL resolve_name(char *name, struct in_addr *return_ip) } } else { - DEBUG(0,("resolve_name: unknown name switch type %s\n", p)); + DEBUG(0,("resolve_name: unknown name switch type %s\n", tok)); } } -- cgit