From 497daed116714a8c3f91162fe02ca81ad33bb6fa Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Thu, 23 Jul 2015 22:56:49 +0200 Subject: 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. --- sys/src/9/port/sysfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- cgit v1.2.3