shithub: riscv

Download patch

ref: c8dd01d5f673d62555ac773a61798901784445de
parent: 7ed22aaeec7a09f2215d08003e2e5c824f903d5d
author: cinap_lenrek <[email protected]>
date: Wed Sep 2 07:41:41 EDT 2015

auth/passwd: fix structure zeroing order

--- a/sys/src/cmd/auth/passwd.c
+++ b/sys/src/cmd/auth/passwd.c
@@ -32,23 +32,24 @@
 
 	fd = authdial(nil, s);
 	if(fd < 0)
-		error("protocol botch: %r");
+		error("authdial: %r");
 
-	/* send ticket request to AS */
-	memset(&tr, 0, sizeof(tr));
-	strcpy(tr.uid, user);
-	tr.type = AuthPass;
-	if(_asrequest(fd, &tr) < 0)
-		error("%r");
-
 	/*
 	 *  get a password from the user and try to decrypt the
 	 *  ticket.  If it doesn't work we've got a bad password,
 	 *  give up.
 	 */
+	memset(&pr, 0, sizeof(pr));
 	readln("Plan 9 Password: ", pr.old, sizeof pr.old, 1);
 	passtokey(&key, pr.old);
 
+	memset(&tr, 0, sizeof(tr));
+	strcpy(tr.uid, user);
+	tr.type = AuthPass;
+
+	/* send ticket request to AS */
+	if(_asrequest(fd, &tr) < 0)
+		error("%r");
 	if(_asgetresp(fd, &t, nil, &key) < 0)
 		error("%r");
 
@@ -57,7 +58,6 @@
 
 	/* loop trying new passwords */
 	for(;;){
-		memset(&pr, 0, sizeof(pr));
 		pr.changesecret = 0;
 		*pr.new = 0;
 		readln("change Plan 9 Password? (y/n) ", buf, sizeof buf, 0);