Mercurial > emacs
changeset 68299:8d40a7886950
(sys_close): If FD is outside [0..MAXDESC) limits, pass it directly to _close.
(sys_dup): Protect against new_fd larger than fd_info[] can handle.
(sys_read): If FD is outside [0..MAXDESC) limits, pass it directly to _read.
(sys_write): If FD is outside [0..MAXDESC) limits, pass it directly to _write.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Fri, 20 Jan 2006 19:12:04 +0000 |
parents | f2e5b42a122e |
children | f283791acd64 |
files | src/w32.c |
diffstat | 1 files changed, 9 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/w32.c Fri Jan 20 14:19:14 2006 +0000 +++ b/src/w32.c Fri Jan 20 19:12:04 2006 +0000 @@ -3426,13 +3426,13 @@ { int rc; - if (fd < 0 || fd >= MAXDESC) + if (fd < 0) { errno = EBADF; return -1; } - if (fd_info[fd].cp) + if (fd < MAXDESC && fd_info[fd].cp) { child_process * cp = fd_info[fd].cp; @@ -3474,7 +3474,7 @@ because socket handles are fully fledged kernel handles. */ rc = _close (fd); - if (rc == 0) + if (rc == 0 && fd < MAXDESC) fd_info[fd].flags = 0; return rc; @@ -3486,7 +3486,7 @@ int new_fd; new_fd = _dup (fd); - if (new_fd >= 0) + if (new_fd >= 0 && new_fd < MAXDESC) { /* duplicate our internal info as well */ fd_info[new_fd] = fd_info[fd]; @@ -3641,13 +3641,13 @@ DWORD waiting; char * orig_buffer = buffer; - if (fd < 0 || fd >= MAXDESC) + if (fd < 0) { errno = EBADF; return -1; } - if (fd_info[fd].flags & (FILE_PIPE | FILE_SOCKET)) + if (fd < MAXDESC && fd_info[fd].flags & (FILE_PIPE | FILE_SOCKET)) { child_process *cp = fd_info[fd].cp; @@ -3785,13 +3785,13 @@ { int nchars; - if (fd < 0 || fd >= MAXDESC) + if (fd < 0) { errno = EBADF; return -1; } - if (fd_info[fd].flags & (FILE_PIPE | FILE_SOCKET)) + if (fd < MAXDESC && fd_info[fd].flags & (FILE_PIPE | FILE_SOCKET)) { if ((fd_info[fd].flags & FILE_WRITE) == 0) { @@ -3833,7 +3833,7 @@ } #ifdef HAVE_SOCKETS - if (fd_info[fd].flags & FILE_SOCKET) + if (fd < MAXDESC && fd_info[fd].flags & FILE_SOCKET) { unsigned long nblock = 0; if (winsock_lib == NULL) abort ();