summaryrefslogtreecommitdiff
path: root/source3/lib/util.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-11-02 09:27:04 -0700
committerJeremy Allison <jra@samba.org>2007-11-02 09:27:04 -0700
commit78cdd6e7eca44346377346fa6d84a9b59a8f5624 (patch)
tree930128ab60da2b4ec48bc745c29d0601b96d7f28 /source3/lib/util.c
parent10500184bf7aac4c1036a807ad4f57d2016d7bd0 (diff)
downloadsamba-78cdd6e7eca44346377346fa6d84a9b59a8f5624.tar.gz
samba-78cdd6e7eca44346377346fa6d84a9b59a8f5624.tar.bz2
samba-78cdd6e7eca44346377346fa6d84a9b59a8f5624.zip
Fix state_path to take a const string, not use pstring.
Jeremy. (This used to be commit 8c73e19f51d6e3f520cf44dd22f9b9584d4b460f)
Diffstat (limited to 'source3/lib/util.c')
-rw-r--r--source3/lib/util.c18
1 files changed, 11 insertions, 7 deletions
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;
}
/**