summaryrefslogtreecommitdiff
path: root/source3/nmbd
diff options
context:
space:
mode:
Diffstat (limited to 'source3/nmbd')
-rw-r--r--source3/nmbd/nmbd_sendannounce.c14
-rw-r--r--source3/nmbd/nmbd_synclists.c18
-rw-r--r--source3/nmbd/nmbd_winsserver.c49
3 files changed, 51 insertions, 30 deletions
diff --git a/source3/nmbd/nmbd_sendannounce.c b/source3/nmbd/nmbd_sendannounce.c
index a4e646771f..3cc9bb52b0 100644
--- a/source3/nmbd/nmbd_sendannounce.c
+++ b/source3/nmbd/nmbd_sendannounce.c
@@ -457,10 +457,11 @@ void announce_remote(time_t t)
char *s;
const char *ptr;
static time_t last_time = 0;
- fstring s2;
+ char *s2;
struct in_addr addr;
char *comment;
int stype = lp_default_server_announce();
+ TALLOC_CTX *frame = NULL;
if (last_time && (t < (last_time + REMOTE_ANNOUNCE_INTERVAL)))
return;
@@ -473,7 +474,8 @@ void announce_remote(time_t t)
comment = string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH);
- for (ptr=s; next_token(&ptr,s2,NULL,sizeof(s2)); ) {
+ frame = talloc_stackframe();
+ for (ptr=s; next_token_talloc(frame,&ptr,&s2,NULL); ) {
/* The entries are of the form a.b.c.d/WORKGROUP with
WORKGROUP being optional */
const char *wgroup;
@@ -510,6 +512,7 @@ void announce_remote(time_t t)
comment);
}
}
+ TALLOC_FREE(frame);
}
/****************************************************************************
@@ -522,12 +525,13 @@ void browse_sync_remote(time_t t)
char *s;
const char *ptr;
static time_t last_time = 0;
- fstring s2;
+ char *s2;
struct in_addr addr;
struct work_record *work;
char outbuf[1024];
char *p;
unstring myname;
+ TALLOC_CTX *frame = NULL;
if (last_time && (t < (last_time + REMOTE_ANNOUNCE_INTERVAL)))
return;
@@ -567,7 +571,8 @@ for workgroup %s on subnet %s.\n", lp_workgroup(), FIRST_SUBNET->subnet_name ));
p = skip_string(outbuf,sizeof(outbuf),p);
- for (ptr=s; next_token(&ptr,s2,NULL,sizeof(s2)); ) {
+ frame = talloc_stackframe();
+ for (ptr=s; next_token_talloc(frame,&ptr,&s2,NULL); ) {
/* The entries are of the form a.b.c.d */
(void)interpret_addr2(&addr,s2);
@@ -577,4 +582,5 @@ for workgroup %s on subnet %s.\n", lp_workgroup(), FIRST_SUBNET->subnet_name ));
send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf),
global_myname(), 0x0, "*", 0x0, addr, FIRST_SUBNET->myip, DGRAM_PORT);
}
+ TALLOC_FREE(frame);
}
diff --git a/source3/nmbd/nmbd_synclists.c b/source3/nmbd/nmbd_synclists.c
index 8abf60c8ce..147df68a69 100644
--- a/source3/nmbd/nmbd_synclists.c
+++ b/source3/nmbd/nmbd_synclists.c
@@ -201,7 +201,7 @@ done:
Handle one line from a completed sync file.
**********************************************************************/
-static void complete_one(struct sync_record *s,
+static void complete_one(struct sync_record *s,
char *sname, uint32 stype, char *comment)
{
struct work_record *work;
@@ -258,9 +258,10 @@ static void complete_one(struct sync_record *s,
static void complete_sync(struct sync_record *s)
{
XFILE *f;
- unstring server, type_str;
+ char *server;
+ char *type_str;
unsigned type;
- fstring comment;
+ char *comment;
char line[1024];
const char *ptr;
int count=0;
@@ -271,15 +272,18 @@ static void complete_sync(struct sync_record *s)
return;
while (!x_feof(f)) {
+ TALLOC_CTX *frame = NULL;
if (!fgets_slash(line,sizeof(line),f))
continue;
ptr = line;
- if (!next_token(&ptr,server,NULL,sizeof(server)) ||
- !next_token(&ptr,type_str,NULL, sizeof(type_str)) ||
- !next_token(&ptr,comment,NULL, sizeof(comment))) {
+ frame = talloc_stackframe();
+ if (!next_token_talloc(frame,&ptr,&server,NULL) ||
+ !next_token_talloc(frame,&ptr,&type_str,NULL) ||
+ !next_token_talloc(frame,&ptr,&comment,NULL)) {
+ TALLOC_FREE(frame);
continue;
}
@@ -288,8 +292,8 @@ static void complete_sync(struct sync_record *s)
complete_one(s, server, type, comment);
count++;
+ TALLOC_FREE(frame);
}
-
x_fclose(f);
unlink(s->fname);
diff --git a/source3/nmbd/nmbd_winsserver.c b/source3/nmbd/nmbd_winsserver.c
index 88cc395af4..7dafa66b11 100644
--- a/source3/nmbd/nmbd_winsserver.c
+++ b/source3/nmbd/nmbd_winsserver.c
@@ -601,30 +601,33 @@ bool initialise_wins(void)
}
while (!x_feof(fp)) {
- fstring name_str;
- char ip_str[1024];
- fstring ttl_str, nb_flags_str;
+ char *name_str = NULL;
+ char *ip_str = NULL;
+ char *ttl_str = NULL, *nb_flags_str = NULL;
unsigned int num_ips;
- char *name;
- struct in_addr *ip_list;
+ char *name = NULL;
+ struct in_addr *ip_list = NULL;
int type = 0;
int nb_flags;
int ttl;
const char *ptr;
- char *p;
+ char *p = NULL;
bool got_token;
bool was_ip;
int i;
unsigned int hash;
int version;
+ TALLOC_CTX *frame = NULL;
/* Read a line from the wins.dat file. Strips whitespace
from the beginning and end of the line. */
- if (!fgets_slash(line,sizeof(line),fp))
+ if (!fgets_slash(line,sizeof(line),fp)) {
continue;
+ }
- if (*line == '#')
+ if (*line == '#') {
continue;
+ }
if (strncmp(line,"VERSION ", 8) == 0) {
if (sscanf(line,"VERSION %d %u", &version, &hash) != 2 ||
@@ -645,13 +648,16 @@ bool initialise_wins(void)
* time to actually parse them into the ip_list array.
*/
- if (!next_token(&ptr,name_str,NULL,sizeof(name_str))) {
+ frame = talloc_stackframe();
+ if (!next_token_talloc(frame,&ptr,&name_str,NULL)) {
DEBUG(0,("initialise_wins: Failed to parse name when parsing line %s\n", line ));
+ TALLOC_FREE(frame);
continue;
}
- if (!next_token(&ptr,ttl_str,NULL,sizeof(ttl_str))) {
+ if (!next_token_talloc(frame,&ptr,ttl_str,NULL)) {
DEBUG(0,("initialise_wins: Failed to parse time to live when parsing line %s\n", line ));
+ TALLOC_FREE(frame);
continue;
}
@@ -660,22 +666,24 @@ bool initialise_wins(void)
*/
num_ips = 0;
do {
- got_token = next_token(&ptr,ip_str,NULL,sizeof(ip_str));
+ got_token = next_token_talloc(frame,&ptr,&ip_str,NULL);
was_ip = False;
if(got_token && strchr(ip_str, '.')) {
num_ips++;
was_ip = True;
}
- } while( got_token && was_ip);
+ } while(got_token && was_ip);
if(num_ips == 0) {
DEBUG(0,("initialise_wins: Missing IP address when parsing line %s\n", line ));
+ TALLOC_FREE(frame);
continue;
}
if(!got_token) {
DEBUG(0,("initialise_wins: Missing nb_flags when parsing line %s\n", line ));
+ TALLOC_FREE(frame);
continue;
}
@@ -683,20 +691,21 @@ bool initialise_wins(void)
if((ip_list = SMB_MALLOC_ARRAY( struct in_addr, num_ips)) == NULL) {
DEBUG(0,("initialise_wins: Malloc fail !\n"));
x_fclose(fp);
+ TALLOC_FREE(frame);
return False;
}
/* Reset and re-parse the line. */
ptr = line;
- next_token(&ptr,name_str,NULL,sizeof(name_str));
- next_token(&ptr,ttl_str,NULL,sizeof(ttl_str));
+ next_token_talloc(frame,&ptr,&name_str,NULL);
+ next_token_talloc(frame,&ptr,&ttl_str,NULL);
for(i = 0; i < num_ips; i++) {
- next_token(&ptr, ip_str, NULL, sizeof(ip_str));
+ next_token_talloc(frame,&ptr, &ip_str, NULL);
(void)interpret_addr2(&ip_list[i], ip_str);
}
- next_token(&ptr,nb_flags_str,NULL, sizeof(nb_flags_str));
+ next_token_talloc(frame,&ptr,&nb_flags_str,NULL);
- /*
+ /*
* Deal with SELF or REGISTER name encoding. Default is REGISTER
* for compatibility with old nmbds.
*/
@@ -704,6 +713,7 @@ bool initialise_wins(void)
if(nb_flags_str[strlen(nb_flags_str)-1] == 'S') {
DEBUG(5,("initialise_wins: Ignoring SELF name %s\n", line));
SAFE_FREE(ip_list);
+ TALLOC_FREE(frame);
continue;
}
@@ -740,9 +750,10 @@ bool initialise_wins(void)
name, type, ttl, inet_ntoa(ip_list[0]), nb_flags));
}
+ TALLOC_FREE(frame);
SAFE_FREE(ip_list);
- }
-
+ }
+
x_fclose(fp);
return True;
}