kernel: make sure fd is in range in fdclose()
as the Fgrp can be shared with other processes, we have to recheck the fd index after locking the Fgrp in fdclose() to make sure not to read beyond the bounds of the fd array.
This commit is contained in:
parent
323184d775
commit
497daed116
1 changed files with 1 additions and 1 deletions
|
@ -294,7 +294,7 @@ fdclose(int fd, int flag)
|
|||
Fgrp *f = up->fgrp;
|
||||
|
||||
lock(f);
|
||||
c = f->fd[fd];
|
||||
c = fd <= f->maxfd ? f->fd[fd] : nil;
|
||||
if(c == nil || (flag != 0 && (c->flag&flag) == 0)){
|
||||
unlock(f);
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue