From 78cdd6e7eca44346377346fa6d84a9b59a8f5624 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 2 Nov 2007 09:27:04 -0700 Subject: Fix state_path to take a const string, not use pstring. Jeremy. (This used to be commit 8c73e19f51d6e3f520cf44dd22f9b9584d4b460f) --- source3/lib/util.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/util.c b/source3/lib/util.c index c8f0c3121f..0ae80c1f9e 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -550,7 +550,7 @@ int set_message(char *buf,int num_words,int num_bytes,bool zero) int set_message_bcc(char *buf,int num_bytes) { int num_words = CVAL(buf,smb_wct); - SSVAL(buf,smb_vwv + num_words*SIZEOFWORD,num_bytes); + SSVAL(buf,smb_vwv + num_words*SIZEOFWORD,num_bytes); smb_setlen(buf,smb_size + num_words*2 + num_bytes - 4); return (smb_size + num_words*2 + num_bytes); } @@ -2450,21 +2450,25 @@ char *data_path(const char *name) /***************************************************************** a useful function for returning a path in the Samba state directory *****************************************************************/ -char *state_path(char *name) + +char *state_path(const char *name) { - pstring fname; + TALLOC_CTX *ctx = talloc_tos(); + char *fname = talloc_strdup(ctx, dyn_STATEDIR()); - pstrcpy(fname,dyn_STATEDIR()); + if (!fname) { + smb_panic("state_path: out of memory"); + } trim_string(fname,"","/"); if (!directory_exist(fname,NULL)) { mkdir(fname,0755); } - pstrcat(fname,"/"); - pstrcat(fname,name); + fname = talloc_asprintf(ctx, "%s/%s", + fname, name); - return talloc_strdup(talloc_tos(), fname); + return fname; } /** -- cgit