From a6054e2b3523b51b379e3e311978912868c1d7fb Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 17 Jan 2020 19:30:36 +0100 Subject: [PATCH] s3/rpc_server: use talloc_alpha_strcpy() in _winreg_InitiateSystemShutdownEx() Signed-off-by: Ralph Boehme Reviewed-by: Andreas Schneider --- source3/rpc_server/winreg/srv_winreg_nt.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/source3/rpc_server/winreg/srv_winreg_nt.c b/source3/rpc_server/winreg/srv_winreg_nt.c index 6c3270d886a..05dc051e247 100644 --- a/source3/rpc_server/winreg/srv_winreg_nt.c +++ b/source3/rpc_server/winreg/srv_winreg_nt.c @@ -522,7 +522,6 @@ WERROR _winreg_InitiateSystemShutdownEx(struct pipes_struct *p, const struct loadparm_substitution *lp_sub = loadparm_s3_global_substitution(); char *shutdown_script = NULL; - char *msg = NULL; char *chkmsg = NULL; fstring str_timeout; fstring str_reason; @@ -542,14 +541,12 @@ WERROR _winreg_InitiateSystemShutdownEx(struct pipes_struct *p, /* pull the message string and perform necessary sanity checks on it */ if ( r->in.message && r->in.message->string ) { - if ( (msg = talloc_strdup(p->mem_ctx, r->in.message->string )) == NULL ) { + chkmsg = talloc_alpha_strcpy(p->mem_ctx, + r->in.message->string, + NULL); + if (chkmsg == NULL) { return WERR_NOT_ENOUGH_MEMORY; } - chkmsg = talloc_array(p->mem_ctx, char, strlen(msg)+1); - if (!chkmsg) { - return WERR_NOT_ENOUGH_MEMORY; - } - alpha_strcpy(chkmsg, msg, NULL, strlen(msg)+1); } fstr_sprintf(str_timeout, "%d", r->in.timeout); -- 2.47.2