Skip to content

Commit a91b98e

Browse files
committed
Check for invalid filter index in windows_kevent_copyout
1 parent e02fab6 commit a91b98e

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/windows/platform.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,17 @@ windows_kevent_copyout(struct kqueue *kq, int nready,
134134
{
135135
struct filter *filt;
136136
struct knote* kn;
137-
int rv, nret;
137+
int rv, nret, filt_index;
138138

139139
//FIXME: not true for EVFILT_IOCP
140140
kn = (struct knote *) iocp_buf.overlap;
141-
filt = &kq->kq_filt[~(kn->kev.filter)];
141+
filt_index = ~(kn->kev.filter);
142+
if (filt_index < 0 || filt_index >= EVFILT_SYSCOUNT) {
143+
dbg_puts("bad filter index in windows_kevent_copyout");
144+
return 0;
145+
}
146+
filt = &kq->kq_filt[filt_index];
147+
142148
rv = filt->kf_copyout(eventlist, nevents, filt, kn, &iocp_buf);
143149
if (unlikely(rv < 0)) {
144150
dbg_puts("knote_copyout failed");

0 commit comments

Comments
 (0)