From f970961773b3dd072c2e3cd0ac37bb37360855ac Mon Sep 17 00:00:00 2001 From: Alexander Leidinger Date: Mon, 9 Jun 2003 16:45:37 +0000 Subject: [PATCH] Sanity check fd before using it as an array index. Noticed by: ted@NLnetLabs.nl (Ted Lindgreen) Approved by: ru --- lib/libc_r/uthread/uthread_close.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/libc_r/uthread/uthread_close.c b/lib/libc_r/uthread/uthread_close.c index 0847fcd1152..ba291a3c884 100644 --- a/lib/libc_r/uthread/uthread_close.c +++ b/lib/libc_r/uthread/uthread_close.c @@ -49,7 +49,8 @@ _close(int fd) struct stat sb; struct fd_table_entry *entry; - if ((fd == _thread_kern_pipe[0]) || (fd == _thread_kern_pipe[1]) || + if ((fd < 0) || (fd >= _thread_dtablesize) || + (fd == _thread_kern_pipe[0]) || (fd == _thread_kern_pipe[1]) || (_thread_fd_table[fd] == NULL)) { /* * Don't allow silly programs to close the kernel pipe