From 052efa9a33d7a9a3b9ae9b038f6b3943c85c4bfc Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 13 Nov 2007 12:51:31 -0800 Subject: Remove last pstring from smbd/*.c Jeremy. (This used to be commit f1680bada913af4eaf5c0d686983018d6c8b3e5f) --- source3/smbd/message.c | 51 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 11 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index b044b6f92d..12a4bc0d54 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -38,7 +38,8 @@ static fstring msgto; static void msg_deliver(void) { - pstring name; + TALLOC_CTX *ctx = talloc_tos(); + char *name = NULL; int i; int fd; char *msg; @@ -52,7 +53,10 @@ static void msg_deliver(void) } /* put it in a temporary file */ - slprintf(name,sizeof(name)-1, "%s/msg.XXXXXX",tmpdir()); + name = talloc_asprintf(ctx, "%s/msg.XXXXXX",tmpdir()); + if (!name) { + return; + } fd = smb_mkstemp(name); if (fd == -1) { @@ -63,7 +67,7 @@ static void msg_deliver(void) /* * Incoming message is in DOS codepage format. Convert to UNIX. */ - + if ((len = (int)convert_string_allocate(NULL,CH_DOS, CH_UNIX, msgbuf, msgpos, (void **)(void *)&msg, True)) < 0 || !msg) { DEBUG(3,("Conversion failed, delivering message in DOS codepage format\n")); for (i = 0; i < msgpos;) { @@ -95,14 +99,39 @@ static void msg_deliver(void) if (*lp_msg_command()) { fstring alpha_msgfrom; fstring alpha_msgto; - pstring s; - - pstrcpy(s,lp_msg_command()); - pstring_sub(s,"%f",alpha_strcpy(alpha_msgfrom,msgfrom,NULL,sizeof(alpha_msgfrom))); - pstring_sub(s,"%t",alpha_strcpy(alpha_msgto,msgto,NULL,sizeof(alpha_msgto))); - standard_sub_basic(current_user_info.smb_name, - current_user_info.domain, s, sizeof(s)); - pstring_sub(s,"%s",name); + char *s = talloc_strdup(ctx, + lp_msg_command()); + + if (!s) { + return; + } + s = talloc_string_sub(ctx, s, "%f", + alpha_strcpy(alpha_msgfrom, + msgfrom, + NULL, + sizeof(alpha_msgfrom))); + if (!s) { + return; + } + s = talloc_string_sub(ctx, s, "%t", + alpha_strcpy(alpha_msgto, + msgto, + NULL, + sizeof(alpha_msgto))); + if (!s) { + return; + } + s = talloc_sub_basic(ctx, + current_user_info.smb_name, + current_user_info.domain, + s); + if (!s) { + return; + } + s = talloc_string_sub(ctx, s, "%s",name); + if (!s) { + return; + } smbrun(s,NULL); } -- cgit