aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/w32.c')
-rw-r--r--src/w32.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/w32.c b/src/w32.c
index 9a51233527d..9860a6cc353 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -3426,13 +3426,13 @@ sys_close (int fd)
3426{ 3426{
3427 int rc; 3427 int rc;
3428 3428
3429 if (fd < 0 || fd >= MAXDESC) 3429 if (fd < 0)
3430 { 3430 {
3431 errno = EBADF; 3431 errno = EBADF;
3432 return -1; 3432 return -1;
3433 } 3433 }
3434 3434
3435 if (fd_info[fd].cp) 3435 if (fd < MAXDESC && fd_info[fd].cp)
3436 { 3436 {
3437 child_process * cp = fd_info[fd].cp; 3437 child_process * cp = fd_info[fd].cp;
3438 3438
@@ -3474,7 +3474,7 @@ sys_close (int fd)
3474 because socket handles are fully fledged kernel handles. */ 3474 because socket handles are fully fledged kernel handles. */
3475 rc = _close (fd); 3475 rc = _close (fd);
3476 3476
3477 if (rc == 0) 3477 if (rc == 0 && fd < MAXDESC)
3478 fd_info[fd].flags = 0; 3478 fd_info[fd].flags = 0;
3479 3479
3480 return rc; 3480 return rc;
@@ -3486,7 +3486,7 @@ sys_dup (int fd)
3486 int new_fd; 3486 int new_fd;
3487 3487
3488 new_fd = _dup (fd); 3488 new_fd = _dup (fd);
3489 if (new_fd >= 0) 3489 if (new_fd >= 0 && new_fd < MAXDESC)
3490 { 3490 {
3491 /* duplicate our internal info as well */ 3491 /* duplicate our internal info as well */
3492 fd_info[new_fd] = fd_info[fd]; 3492 fd_info[new_fd] = fd_info[fd];
@@ -3641,13 +3641,13 @@ sys_read (int fd, char * buffer, unsigned int count)
3641 DWORD waiting; 3641 DWORD waiting;
3642 char * orig_buffer = buffer; 3642 char * orig_buffer = buffer;
3643 3643
3644 if (fd < 0 || fd >= MAXDESC) 3644 if (fd < 0)
3645 { 3645 {
3646 errno = EBADF; 3646 errno = EBADF;
3647 return -1; 3647 return -1;
3648 } 3648 }
3649 3649
3650 if (fd_info[fd].flags & (FILE_PIPE | FILE_SOCKET)) 3650 if (fd < MAXDESC && fd_info[fd].flags & (FILE_PIPE | FILE_SOCKET))
3651 { 3651 {
3652 child_process *cp = fd_info[fd].cp; 3652 child_process *cp = fd_info[fd].cp;
3653 3653
@@ -3785,13 +3785,13 @@ sys_write (int fd, const void * buffer, unsigned int count)
3785{ 3785{
3786 int nchars; 3786 int nchars;
3787 3787
3788 if (fd < 0 || fd >= MAXDESC) 3788 if (fd < 0)
3789 { 3789 {
3790 errno = EBADF; 3790 errno = EBADF;
3791 return -1; 3791 return -1;
3792 } 3792 }
3793 3793
3794 if (fd_info[fd].flags & (FILE_PIPE | FILE_SOCKET)) 3794 if (fd < MAXDESC && fd_info[fd].flags & (FILE_PIPE | FILE_SOCKET))
3795 { 3795 {
3796 if ((fd_info[fd].flags & FILE_WRITE) == 0) 3796 if ((fd_info[fd].flags & FILE_WRITE) == 0)
3797 { 3797 {
@@ -3833,7 +3833,7 @@ sys_write (int fd, const void * buffer, unsigned int count)
3833 } 3833 }
3834 3834
3835#ifdef HAVE_SOCKETS 3835#ifdef HAVE_SOCKETS
3836 if (fd_info[fd].flags & FILE_SOCKET) 3836 if (fd < MAXDESC && fd_info[fd].flags & FILE_SOCKET)
3837 { 3837 {
3838 unsigned long nblock = 0; 3838 unsigned long nblock = 0;
3839 if (winsock_lib == NULL) abort (); 3839 if (winsock_lib == NULL) abort ();