summaryrefslogtreecommitdiff
path: root/sys/src/9/port/sysfile.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2015-07-23 22:56:49 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2015-07-23 22:56:49 +0200
commit497daed116714a8c3f91162fe02ca81ad33bb6fa (patch)
tree0d24ed9e786d2635b8283cb6ecdeb38d0a75a6bf /sys/src/9/port/sysfile.c
parent323184d775b92c50bb37fa0b3ae73a16138f8b7e (diff)
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.
Diffstat (limited to 'sys/src/9/port/sysfile.c')
-rw-r--r--sys/src/9/port/sysfile.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/src/9/port/sysfile.c b/sys/src/9/port/sysfile.c
index 77ff43fa3..43d384c2e 100644
--- a/sys/src/9/port/sysfile.c
+++ b/sys/src/9/port/sysfile.c
@@ -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;