wpa: fix error reporting for getptk(), use readn() to read ifstats file
This commit is contained in:
parent
a3b35c224b
commit
745be8ad8e
|
@ -130,7 +130,7 @@ getifstats(char *key, char *val, int nval)
|
||||||
snprint(buf, sizeof(buf), "%s/ifstats", devdir);
|
snprint(buf, sizeof(buf), "%s/ifstats", devdir);
|
||||||
if((fd = open(buf, OREAD)) < 0)
|
if((fd = open(buf, OREAD)) < 0)
|
||||||
return nil;
|
return nil;
|
||||||
n = read(fd, buf, sizeof(buf)-1);
|
n = readn(fd, buf, sizeof(buf)-1);
|
||||||
close(fd);
|
close(fd);
|
||||||
if(n <= 0)
|
if(n <= 0)
|
||||||
return nil;
|
return nil;
|
||||||
|
@ -330,8 +330,10 @@ getptk( uchar smac[Eaddrlen], uchar amac[Eaddrlen],
|
||||||
goto out;
|
goto out;
|
||||||
if((ret = auth_rpc(rpc, "read", nil, 0)) != ARok)
|
if((ret = auth_rpc(rpc, "read", nil, 0)) != ARok)
|
||||||
goto out;
|
goto out;
|
||||||
if(rpc->narg != PTKlen)
|
if(rpc->narg != PTKlen){
|
||||||
|
ret = -1;
|
||||||
goto out;
|
goto out;
|
||||||
|
}
|
||||||
memmove(ptk, rpc->arg, PTKlen);
|
memmove(ptk, rpc->arg, PTKlen);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
out:
|
out:
|
||||||
|
@ -698,9 +700,9 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
memmove(anonce, kd->nonce, sizeof(anonce));
|
memmove(anonce, kd->nonce, sizeof(anonce));
|
||||||
genrandom(snonce, sizeof(snonce));
|
genrandom(snonce, sizeof(snonce));
|
||||||
if(getptk(smac, amac, snonce, anonce, ptk) < 0){
|
if(getptk(smac, amac, snonce, anonce, ptk) != 0){
|
||||||
if(debug != 0)
|
if(debug != 0)
|
||||||
fprint(2, "getptk: %r");
|
fprint(2, "getptk: %r\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue