kernel: devdup: fix dup(n, 0)

A successful dup(n, 0) must not return -1L
This commit is contained in:
Giacomo Tesio 2017-01-17 21:48:30 +01:00
parent 207967f9e8
commit e1a14b49be
1 changed files with 7 additions and 3 deletions

View File

@ -64,12 +64,16 @@ static Chan*
dupcreate(Chan* c, char* name, unsigned long omode, unsigned long perm)
{
FdPair in, out;
int d;
if((omode|OCEXEC) == ~0 && c->qid.path == 0){
in.aslong = perm;
out.aslong = 0;
out.fd[1] = sysdup(in.fd[0], in.fd[1]);
errorl(nil, ~out.aslong);
out.aslong = ~0;
d = sysdup(in.fd[0], in.fd[1]);
if(d >= 0){
out.fd[1] = d;
errorl(nil, ~out.aslong);
}
}
error(Eperm);
}