mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-18 20:39:33 +08:00
* net.cc (cygwin_inet_ntoa): Add parameter checking.
(cygwin_inet_network): Return INADDR_NONE instead of 0 in case of EFAULT. (cygwin_hstrerror): Add parameter checking. (cygwin_rresvport): Ditto. (socketpair): Ditto. * winsup.h (check_null_str): Add extern declaration.
This commit is contained in:
parent
28d3cc021d
commit
b0fa0e6e0f
@ -206,6 +206,8 @@ cygwin_inet_ntoa (struct in_addr in)
|
||||
extern "C" unsigned long
|
||||
cygwin_inet_addr (const char *cp)
|
||||
{
|
||||
if (check_null_str_errno (cp))
|
||||
return INADDR_NONE;
|
||||
unsigned long res = inet_addr (cp);
|
||||
return res;
|
||||
}
|
||||
@ -234,7 +236,7 @@ extern "C" unsigned int
|
||||
cygwin_inet_network (const char *cp)
|
||||
{
|
||||
if (check_null_str_errno (cp))
|
||||
return 0;
|
||||
return INADDR_NONE;
|
||||
unsigned int res = inet_network (cp);
|
||||
return res;
|
||||
}
|
||||
@ -1440,6 +1442,8 @@ cygwin_hstrerror (int err)
|
||||
extern "C" void
|
||||
cygwin_herror (const char *s)
|
||||
{
|
||||
if (check_null_str (s))
|
||||
return;
|
||||
if (cygheap->fdtab.not_open (2))
|
||||
return;
|
||||
|
||||
@ -2229,6 +2233,9 @@ cygwin_rresvport (int *port)
|
||||
int res;
|
||||
sigframe thisframe (mainthread);
|
||||
|
||||
if (check_null_invalid_struct_errno (port))
|
||||
return -1;
|
||||
|
||||
cygheap_fdnew res_fd;
|
||||
if (res_fd < 0)
|
||||
res = -1;
|
||||
@ -2292,6 +2299,9 @@ socketpair (int, int type, int, int *sb)
|
||||
struct sockaddr_in sock_in;
|
||||
int len = sizeof (sock_in);
|
||||
|
||||
if (__check_null_invalid_struct_errno (sb, 2 * sizeof(int)))
|
||||
return -1;
|
||||
|
||||
cygheap_fdnew sb0;
|
||||
if (sb0 < 0)
|
||||
goto done;
|
||||
|
@ -188,6 +188,7 @@ long __stdcall to_time_t (FILETIME * ptr);
|
||||
void __stdcall set_console_title (char *);
|
||||
void set_console_handler ();
|
||||
|
||||
int __stdcall check_null_str (const char *name) __attribute__ ((regparm(1)));
|
||||
int __stdcall check_null_empty_str (const char *name) __attribute__ ((regparm(1)));
|
||||
int __stdcall check_null_empty_str_errno (const char *name) __attribute__ ((regparm(1)));
|
||||
int __stdcall check_null_str_errno (const char *name) __attribute__ ((regparm(1)));
|
||||
|
Loading…
x
Reference in New Issue
Block a user