git: 9front

Download patch

ref: 904989b8ca656037f292e862fc5cdf14ecb57437
parent: 35519466bb77a64b85191f96723825c3848a964d
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Mon Jun 24 13:19:10 EDT 2013

wpa: fix error reporting for getptk(), use readn() to read ifstats file

--- a/sys/src/cmd/aux/wpa.c
+++ b/sys/src/cmd/aux/wpa.c
@@ -130,7 +130,7 @@
 	snprint(buf, sizeof(buf), "%s/ifstats", devdir);
 	if((fd = open(buf, OREAD)) < 0)
 		return nil;
-	n = read(fd, buf, sizeof(buf)-1);
+	n = readn(fd, buf, sizeof(buf)-1);
 	close(fd);
 	if(n <= 0)
 		return nil;
@@ -330,8 +330,10 @@
 		goto out;
 	if((ret = auth_rpc(rpc, "read", nil, 0)) != ARok)
 		goto out;
-	if(rpc->narg != PTKlen)
+	if(rpc->narg != PTKlen){
+		ret = -1;
 		goto out;
+	}
 	memmove(ptk, rpc->arg, PTKlen);
 	ret = 0;
 out:
@@ -698,9 +700,9 @@
 
 			memmove(anonce, kd->nonce, sizeof(anonce));
 			genrandom(snonce, sizeof(snonce));
-			if(getptk(smac, amac, snonce, anonce, ptk) < 0){
+			if(getptk(smac, amac, snonce, anonce, ptk) != 0){
 				if(debug != 0)
-					fprint(2, "getptk: %r");
+					fprint(2, "getptk: %r\n");
 				continue;
 			}
 
--