2006-01-20 Eli Zaretskii <eliz@gnu.org>
+ * w32.c (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.
+
* .gdbinit: Don't dereference Vsystem_type's Lisp_Symbol pointer
if it is NULL.
{
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;
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;
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];
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;
{
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)
{
}
#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 ();