s3-net: Fix Bug #7417. 'net rpc user password' can set the wrong password.
authorGünther Deschner <gd@samba.org>
Sat, 8 May 2010 00:16:37 +0000 (02:16 +0200)
committerKarolin Seeger <kseeger@samba.org>
Thu, 13 Jan 2011 16:58:47 +0000 (17:58 +0100)
Guenther
(cherry picked from commit 7887d99a60387e93ce5ce4a3bfe9117939d1e4c8)
(cherry picked from commit fb4d896217183b0ea2b97016aa84c2d83f7f1323)

source3/utils/net_rpc.c

index 75726b0d61793c66ca02bd79ce0368942f833a2c..aa041720b1c913fb7a5cd4ac4767af055444a663 100644 (file)
@@ -758,8 +758,11 @@ static int rpc_user_password(struct net_context *c, int argc, const char **argv)
                if (asprintf(&prompt, "Enter new password for %s:", argv[0]) == -1) {
                        return -1;
                }
-               u1003.usri1003_password = getpass(prompt);
+               u1003.usri1003_password = talloc_strdup(c, getpass(prompt));
                SAFE_FREE(prompt);
+               if (u1003.usri1003_password == NULL) {
+                       return -1;
+               }
        }
 
        status = NetUserSetInfo(c->opt_host, argv[0], 1003, (uint8_t *)&u1003, &parm_err);