mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-19 04:49:25 +08:00
Ensure that all fhandler_*::read definitions are __stdcall throughout.
* fhandler.cc (fhandler_base::set_inheritance): Be more defensive in debugging code. * fhandler.h: Adjust regparms throughout to reflect passing 'this' parameter. * fhandler_console.cc (fhandler_console::read): Remove unneeded test. Only honor "key down" events. * miscfuncs.cc (strcasestr): Reorganize for efficient code use. (check_null_empty_str_errno): Ditto. (__check_null_invalid_struct_errno): Ditto. (__check_invalid_read_ptr_errno): Ditto. * syscalls.cc (_read): Return 0 when length == 0, as per Single UNIX Specification.
This commit is contained in:
parent
0280c8c0f3
commit
a0626ebe27
@ -1,3 +1,19 @@
|
||||
2001-10-23 Christopher Faylor <cgf@redhat.com>
|
||||
|
||||
Ensure that all fhandler_*::read definitions are __stdcall throughout.
|
||||
* fhandler.cc (fhandler_base::set_inheritance): Be more defensive in
|
||||
debugging code.
|
||||
* fhandler.h: Adjust regparms throughout to reflect passing 'this'
|
||||
parameter.
|
||||
* fhandler_console.cc (fhandler_console::read): Remove unneeded test.
|
||||
Only honor "key down" events.
|
||||
* miscfuncs.cc (strcasestr): Reorganize for efficient code use.
|
||||
(check_null_empty_str_errno): Ditto.
|
||||
(__check_null_invalid_struct_errno): Ditto.
|
||||
(__check_invalid_read_ptr_errno): Ditto.
|
||||
* syscalls.cc (_read): Return 0 when length == 0, as per Single UNIX
|
||||
Specification.
|
||||
|
||||
2001-10-22 Christopher Faylor <cgf@redhat.com>
|
||||
|
||||
* debug.cc (set_errno): Return value of errno that was set, just like
|
||||
|
@ -50,7 +50,7 @@ DEFS = @DEFS@
|
||||
CC:=@CC@
|
||||
# FIXME: Which is it, CC or CC_FOR_TARGET?
|
||||
CC_FOR_TARGET:=$(CC)
|
||||
CFLAGS:=@CFLAGS@
|
||||
CFLAGS:=@CFLAGS@ -Winline
|
||||
CFLAGS+=-MD -fbuiltin
|
||||
CXX:=@CXX@
|
||||
CXXFLAGS:=@CXXFLAGS@
|
||||
|
@ -1611,7 +1611,9 @@ fhandler_dev_null::dump (void)
|
||||
void
|
||||
fhandler_base::set_inheritance (HANDLE &h, int not_inheriting)
|
||||
{
|
||||
#ifdef DEBUGGING
|
||||
HANDLE oh = h;
|
||||
#endif
|
||||
/* Note that we could use SetHandleInformation here but it is not available
|
||||
on all platforms. Test cases seem to indicate that using DuplicateHandle
|
||||
in this fashion does not actually close the original handle, which is
|
||||
@ -1621,7 +1623,8 @@ fhandler_base::set_inheritance (HANDLE &h, int not_inheriting)
|
||||
DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE))
|
||||
debug_printf ("DuplicateHandle failed, %E");
|
||||
#ifdef DEBUGGING
|
||||
setclexec_pid (oh, h, not_inheriting);
|
||||
if (h)
|
||||
setclexec_pid (oh, h, not_inheriting);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -311,11 +311,11 @@ public:
|
||||
|
||||
virtual int open (path_conv * real_path, int flags, mode_t mode = 0);
|
||||
virtual int close ();
|
||||
virtual int __stdcall fstat (struct stat *buf, path_conv *) __attribute__ ((regparm (2)));
|
||||
virtual int __stdcall fstat (struct stat *buf, path_conv *) __attribute__ ((regparm (3)));
|
||||
virtual int ioctl (unsigned int cmd, void *);
|
||||
virtual int fcntl (int cmd, void *);
|
||||
virtual char const * ttyname () { return get_name(); }
|
||||
virtual int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (2)));
|
||||
virtual int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
|
||||
virtual int write (const void *ptr, size_t len);
|
||||
virtual off_t lseek (off_t offset, int whence);
|
||||
virtual int lock (int, struct flock *);
|
||||
@ -395,7 +395,7 @@ public:
|
||||
void set_shutdown_write () {FHSETF (SHUTWR);}
|
||||
|
||||
int write (const void *ptr, size_t len);
|
||||
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (2)));
|
||||
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
|
||||
int ioctl (unsigned int cmd, void *);
|
||||
int fcntl (int cmd, void *);
|
||||
off_t lseek (off_t, int) { return 0; }
|
||||
@ -420,7 +420,7 @@ public:
|
||||
int check_peer_secret_event (struct sockaddr_in *peer, int *secret = NULL);
|
||||
void signal_secret_event ();
|
||||
void close_secret_event ();
|
||||
int __stdcall fstat (struct stat *buf, path_conv *) __attribute__ ((regparm (2)));
|
||||
int __stdcall fstat (struct stat *buf, path_conv *) __attribute__ ((regparm (3)));
|
||||
};
|
||||
|
||||
class fhandler_pipe: public fhandler_base
|
||||
@ -437,7 +437,7 @@ public:
|
||||
select_record *select_except (select_record *s);
|
||||
int ready_for_read (int fd, DWORD howlong, int ignra);
|
||||
void set_close_on_exec (int val);
|
||||
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (2)));
|
||||
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
|
||||
int close ();
|
||||
void create_guard (SECURITY_ATTRIBUTES *sa) {guard = CreateMutex (sa, FALSE, NULL);}
|
||||
int dup (fhandler_base *child);
|
||||
@ -527,7 +527,7 @@ public:
|
||||
|
||||
off_t lseek (off_t offset, int whence);
|
||||
|
||||
int __stdcall fstat (struct stat *buf, path_conv *) __attribute__ ((regparm (2)));
|
||||
int __stdcall fstat (struct stat *buf, path_conv *) __attribute__ ((regparm (3)));
|
||||
|
||||
int dup (fhandler_base *child);
|
||||
|
||||
@ -557,8 +557,8 @@ public:
|
||||
int close ();
|
||||
int lock (int, struct flock *);
|
||||
BOOL is_device () { return FALSE; }
|
||||
int __stdcall fstat (struct stat *buf, path_conv *pc) __attribute__ ((regparm (2)));
|
||||
int __stdcall fstat_helper (struct stat *buf) __attribute__ ((regparm (1)));
|
||||
int __stdcall fstat (struct stat *buf, path_conv *pc) __attribute__ ((regparm (3)));
|
||||
int __stdcall fstat_helper (struct stat *buf) __attribute__ ((regparm (2)));
|
||||
|
||||
HANDLE mmap (caddr_t *addr, size_t len, DWORD access, int flags, off_t off);
|
||||
int munmap (HANDLE h, caddr_t addr, size_t len);
|
||||
@ -748,7 +748,7 @@ public:
|
||||
|
||||
int write (const void *ptr, size_t len);
|
||||
void doecho (const void *str, DWORD len) { (void) write (str, len); }
|
||||
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (2)));
|
||||
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
|
||||
int close ();
|
||||
|
||||
int tcflush (int);
|
||||
@ -819,7 +819,7 @@ public:
|
||||
|
||||
int open (path_conv *, int flags, mode_t mode = 0);
|
||||
int write (const void *ptr, size_t len);
|
||||
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (2)));
|
||||
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
|
||||
void init (HANDLE, DWORD, mode_t);
|
||||
|
||||
int tcsetattr (int a, const struct termios *t);
|
||||
@ -846,7 +846,7 @@ public:
|
||||
int accept_input ();
|
||||
int open (path_conv *, int flags, mode_t mode = 0);
|
||||
int write (const void *ptr, size_t len);
|
||||
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (2)));
|
||||
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
|
||||
int close ();
|
||||
|
||||
int tcsetattr (int a, const struct termios *t);
|
||||
@ -892,7 +892,7 @@ public:
|
||||
fhandler_dev_zero ();
|
||||
int open (path_conv *, int flags, mode_t mode = 0);
|
||||
int write (const void *ptr, size_t len);
|
||||
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (2)));
|
||||
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
|
||||
off_t lseek (off_t offset, int whence);
|
||||
int close (void);
|
||||
|
||||
@ -915,7 +915,7 @@ public:
|
||||
int get_unit () { return unit; }
|
||||
int open (path_conv *, int flags, mode_t mode = 0);
|
||||
int write (const void *ptr, size_t len);
|
||||
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (2)));
|
||||
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
|
||||
off_t lseek (off_t offset, int whence);
|
||||
int close (void);
|
||||
int dup (fhandler_base *child);
|
||||
@ -936,10 +936,10 @@ public:
|
||||
|
||||
int open (path_conv *, int flags, mode_t mode = 0);
|
||||
int write (const void *ptr, size_t ulen);
|
||||
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (2)));
|
||||
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
|
||||
off_t lseek (off_t offset, int whence);
|
||||
int close (void);
|
||||
int __stdcall fstat (struct stat *buf, path_conv *) __attribute__ ((regparm (2)));
|
||||
int __stdcall fstat (struct stat *buf, path_conv *) __attribute__ ((regparm (3)));
|
||||
int dup (fhandler_base *child);
|
||||
|
||||
HANDLE mmap (caddr_t *addr, size_t len, DWORD access, int flags, off_t off);
|
||||
@ -958,7 +958,7 @@ public:
|
||||
int is_windows (void) { return 1; }
|
||||
int open (path_conv *, int flags, mode_t mode = 0);
|
||||
int write (const void *ptr, size_t len);
|
||||
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (2)));
|
||||
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
|
||||
off_t lseek (off_t offset, int whence);
|
||||
int close (void);
|
||||
|
||||
@ -983,7 +983,7 @@ public:
|
||||
int is_windows (void) { return 1; }
|
||||
int open (path_conv *, int flags, mode_t mode = 0);
|
||||
int write (const void *ptr, size_t len);
|
||||
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (2)));
|
||||
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
|
||||
int ioctl (unsigned int cmd, void *);
|
||||
off_t lseek (off_t, int) { return 0; }
|
||||
int close (void) { return 0; }
|
||||
@ -1010,7 +1010,7 @@ public:
|
||||
|
||||
int open (path_conv *, int flags, mode_t mode = 0);
|
||||
int write (const void *ptr, size_t len);
|
||||
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (2)));
|
||||
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
|
||||
int ioctl (unsigned int cmd, void *);
|
||||
off_t lseek (off_t, int);
|
||||
int close (void);
|
||||
|
@ -184,7 +184,7 @@ fhandler_dev_clipboard::write (const void *buf, size_t len)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
int __stdcall
|
||||
fhandler_dev_clipboard::read (void *ptr, size_t len)
|
||||
{
|
||||
HGLOBAL hglb;
|
||||
|
@ -195,12 +195,9 @@ fhandler_console::set_cursor_maybe ()
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
int __stdcall
|
||||
fhandler_console::read (void *pv, size_t buflen)
|
||||
{
|
||||
if (!buflen)
|
||||
return 0;
|
||||
|
||||
HANDLE h = get_io_handle ();
|
||||
|
||||
#define buf ((char *) pv)
|
||||
@ -262,6 +259,9 @@ fhandler_console::read (void *pv, size_t buflen)
|
||||
#define virtual_key_code (input_rec.Event.KeyEvent.wVirtualKeyCode)
|
||||
#define control_key_state (input_rec.Event.KeyEvent.dwControlKeyState)
|
||||
|
||||
if (!input_rec.Event.KeyEvent.bKeyDown)
|
||||
continue;
|
||||
|
||||
#ifdef DEBUGGING
|
||||
/* allow manual switching to/from raw mode via ctrl-alt-scrolllock */
|
||||
if (input_rec.Event.KeyEvent.bKeyDown &&
|
||||
@ -310,7 +310,7 @@ fhandler_console::read (void *pv, size_t buflen)
|
||||
tmp[1] = ich;
|
||||
/* Need this check since US code page seems to have a bug when
|
||||
converting a CTRL-U. */
|
||||
if ((unsigned char)ich > 0x7f)
|
||||
if ((unsigned char) ich > 0x7f)
|
||||
con_to_str (tmp + 1, tmp + 1, 1);
|
||||
/* Determine if the keystroke is modified by META. The tricky
|
||||
part is to distinguish whether the right Alt key should be
|
||||
|
@ -476,7 +476,7 @@ fhandler_dev_dsp::write (const void *ptr, size_t len)
|
||||
return len;
|
||||
}
|
||||
|
||||
int
|
||||
int __stdcall
|
||||
fhandler_dev_dsp::read (void *ptr, size_t len)
|
||||
{
|
||||
return len;
|
||||
|
@ -177,7 +177,7 @@ fhandler_dev_mem::write (const void *ptr, size_t ulen)
|
||||
return ulen;
|
||||
}
|
||||
|
||||
int
|
||||
int __stdcall
|
||||
fhandler_dev_mem::read (void *ptr, size_t ulen)
|
||||
{
|
||||
if (!ulen || pos >= mem_size)
|
||||
|
@ -109,7 +109,7 @@ fhandler_dev_random::pseudo_read (void *ptr, size_t len)
|
||||
return len;
|
||||
}
|
||||
|
||||
int
|
||||
int __stdcall
|
||||
fhandler_dev_random::read (void *ptr, size_t len)
|
||||
{
|
||||
if (!len)
|
||||
|
@ -247,7 +247,7 @@ fhandler_socket::fstat (struct stat *buf, path_conv *pc)
|
||||
return fh.fstat (buf, pc);
|
||||
}
|
||||
|
||||
int
|
||||
int __stdcall
|
||||
fhandler_socket::read (void *ptr, size_t len)
|
||||
{
|
||||
sigframe thisframe (mainthread);
|
||||
|
@ -619,7 +619,7 @@ fhandler_tty_slave::write (const void *ptr, size_t len)
|
||||
return towrite;
|
||||
}
|
||||
|
||||
int
|
||||
int __stdcall
|
||||
fhandler_tty_slave::read (void *ptr, size_t len)
|
||||
{
|
||||
DWORD n;
|
||||
@ -1032,7 +1032,7 @@ fhandler_pty_master::write (const void *ptr, size_t len)
|
||||
return len;
|
||||
}
|
||||
|
||||
int
|
||||
int __stdcall
|
||||
fhandler_pty_master::read (void *ptr, size_t len)
|
||||
{
|
||||
return process_slave_output ((char *) ptr, len, pktmode);
|
||||
|
@ -79,7 +79,7 @@ fhandler_windows::write (const void *buf, size_t)
|
||||
return SendMessage (ptr->hwnd, ptr->message, ptr->wParam, ptr->lParam);
|
||||
}
|
||||
|
||||
int
|
||||
int __stdcall
|
||||
fhandler_windows::read (void *buf, size_t len)
|
||||
{
|
||||
MSG *ptr = (MSG *) buf;
|
||||
|
@ -34,7 +34,7 @@ fhandler_dev_zero::write (const void *, size_t len)
|
||||
return len;
|
||||
}
|
||||
|
||||
int
|
||||
int __stdcall
|
||||
fhandler_dev_zero::read (void *ptr, size_t len)
|
||||
{
|
||||
memset(ptr, 0, len);
|
||||
|
@ -118,13 +118,10 @@ strcasestr (const char *searchee, const char *lookfor)
|
||||
int __stdcall
|
||||
check_null_empty_str (const char *name)
|
||||
{
|
||||
if (!name || IsBadStringPtr (name, MAX_PATH))
|
||||
return EFAULT;
|
||||
if (name && !IsBadStringPtr (name, MAX_PATH))
|
||||
return !*name ? ENOENT : 0;
|
||||
|
||||
if (!*name)
|
||||
return ENOENT;
|
||||
|
||||
return 0;
|
||||
return EFAULT;
|
||||
}
|
||||
|
||||
int __stdcall
|
||||
@ -139,26 +136,25 @@ check_null_empty_str_errno (const char *name)
|
||||
int __stdcall
|
||||
__check_null_invalid_struct (const void *s, unsigned sz)
|
||||
{
|
||||
if (!s || IsBadWritePtr ((void *) s, sz))
|
||||
return EFAULT;
|
||||
if (s && !IsBadWritePtr ((void *) s, sz))
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
return EFAULT;
|
||||
}
|
||||
|
||||
int __stdcall
|
||||
__check_null_invalid_struct_errno (const void *s, unsigned sz)
|
||||
{
|
||||
int __err;
|
||||
if ((__err = __check_null_invalid_struct (s, sz)))
|
||||
set_errno (__err);
|
||||
return __err;
|
||||
int err;
|
||||
if ((err = __check_null_invalid_struct (s, sz)))
|
||||
set_errno (err);
|
||||
return err;
|
||||
}
|
||||
|
||||
int __stdcall
|
||||
__check_invalid_read_ptr_errno (const void *s, unsigned sz)
|
||||
{
|
||||
if (!s || IsBadReadPtr ((void *) s, sz))
|
||||
return set_errno (EFAULT);
|
||||
|
||||
return 0;
|
||||
if (s && !IsBadReadPtr ((void *) s, sz))
|
||||
return 0;
|
||||
return set_errno (EFAULT);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ fhandler_pipe::set_close_on_exec (int val)
|
||||
set_inheritance (writepipe_exists, val);
|
||||
}
|
||||
|
||||
int
|
||||
int __stdcall
|
||||
fhandler_pipe::read (void *in_ptr, size_t in_len)
|
||||
{
|
||||
int res = this->fhandler_base::read (in_ptr, in_len);
|
||||
|
@ -287,6 +287,9 @@ setsid (void)
|
||||
extern "C" ssize_t
|
||||
_read (int fd, void *ptr, size_t len)
|
||||
{
|
||||
if (len == 0)
|
||||
return 0;
|
||||
|
||||
if (__check_null_invalid_struct_errno (ptr, len))
|
||||
return -1;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user