s3/rpc_server: use talloc_alpha_strcpy() in _winreg_InitiateSystemShutdownEx()
authorRalph Boehme <slow@samba.org>
Fri, 17 Jan 2020 18:30:36 +0000 (19:30 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 6 Feb 2020 10:17:43 +0000 (10:17 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/rpc_server/winreg/srv_winreg_nt.c

index 6c3270d886a1e9692998d4137e6bd760f194edea..05dc051e24757566906e03989c62d3d9b01a4da5 100644 (file)
@@ -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);