summaryrefslogtreecommitdiff
path: root/source3/nmbd/nmbd_synclists.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-11-19 15:15:09 -0800
committerJeremy Allison <jra@samba.org>2007-11-19 15:15:09 -0800
commit9a41314ce8582875e0ec59efb670279f39b42ce3 (patch)
tree8d32fb934b30f4080673338460029b489d4d6e2d /source3/nmbd/nmbd_synclists.c
parent551f9e7a6ccfefa48674f3b6a857485c60dfc2eb (diff)
downloadsamba-9a41314ce8582875e0ec59efb670279f39b42ce3.tar.gz
samba-9a41314ce8582875e0ec59efb670279f39b42ce3.tar.bz2
samba-9a41314ce8582875e0ec59efb670279f39b42ce3.zip
Remove pstring from nmbd.
Jeremy. (This used to be commit a317f70c229f7730279eaa323f7ebfd499257f76)
Diffstat (limited to 'source3/nmbd/nmbd_synclists.c')
-rw-r--r--source3/nmbd/nmbd_synclists.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/source3/nmbd/nmbd_synclists.c b/source3/nmbd/nmbd_synclists.c
index 300368cd60..8abf60c8ce 100644
--- a/source3/nmbd/nmbd_synclists.c
+++ b/source3/nmbd/nmbd_synclists.c
@@ -32,7 +32,7 @@ struct sync_record {
struct sync_record *next, *prev;
unstring workgroup;
unstring server;
- pstring fname;
+ char *fname;
struct in_addr ip;
pid_t pid;
};
@@ -159,15 +159,18 @@ done:
if (!s) goto done;
ZERO_STRUCTP(s);
-
+
unstrcpy(s->workgroup, work->work_group);
unstrcpy(s->server, name);
s->ip = ip;
- slprintf(s->fname, sizeof(pstring)-1,
- "%s/sync.%d", lp_lockdir(), counter++);
+ if (asprintf(&s->fname, "%s/sync.%d", lp_lockdir(), counter++) < 0) {
+ SAFE_FREE(s);
+ goto done;
+ }
+ /* Safe to use as 0 means no size change. */
all_string_sub(s->fname,"//", "/", 0);
-
+
DLIST_ADD(syncs, s);
/* the parent forks and returns, leaving the child to do the
@@ -183,7 +186,7 @@ done:
fp = x_fopen(s->fname,O_WRONLY|O_CREAT|O_TRUNC, 0644);
if (!fp) {
END_PROFILE(sync_browse_lists);
- _exit(1);
+ _exit(1);
}
sync_child(name, nm_type, work->work_group, ip, local, servers,
@@ -247,7 +250,7 @@ static void complete_one(struct sync_record *s,
/* Create the server in the workgroup. */
create_server_on_workgroup(work, sname,stype, lp_max_ttl(), comment);
}
-
+
/**********************************************************************
Read the completed sync info.
**********************************************************************/
@@ -257,8 +260,8 @@ static void complete_sync(struct sync_record *s)
XFILE *f;
unstring server, type_str;
unsigned type;
- pstring comment;
- pstring line;
+ fstring comment;
+ char line[1024];
const char *ptr;
int count=0;
@@ -266,12 +269,12 @@ static void complete_sync(struct sync_record *s)
if (!f)
return;
-
+
while (!x_feof(f)) {
-
- if (!fgets_slash(line,sizeof(pstring),f))
+
+ if (!fgets_slash(line,sizeof(line),f))
continue;
-
+
ptr = line;
if (!next_token(&ptr,server,NULL,sizeof(server)) ||
@@ -309,7 +312,7 @@ void sync_check_completion(void)
/* it has completed - grab the info */
complete_sync(s);
DLIST_REMOVE(syncs, s);
- ZERO_STRUCTP(s);
+ SAFE_FREE(s->fname);
SAFE_FREE(s);
}
}