[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/emacs-24 r111267: Improve error reporting a
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/emacs-24 r111267: Improve error reporting as part of solving bug #13546 on MS-Windows. |
Date: |
Fri, 15 Feb 2013 11:01:13 +0200 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 111267
fixes bug: http://debbugs.gnu.org/13546
committer: Eli Zaretskii <address@hidden>
branch nick: emacs-24
timestamp: Fri 2013-02-15 11:01:13 +0200
message:
Improve error reporting as part of solving bug #13546 on MS-Windows.
src/w32.c (sys_socket, sys_bind, sys_connect, sys_gethostname)
(sys_gethostbyname, sys_getservbyname, sys_getpeername)
(sys_shutdown, sys_setsockopt, sys_listen, sys_getsockname)
(sys_accept, sys_recvfrom, sys_sendto, fcntl): In case of failure,
make sure errno is set to an appropriate value. (Bug#13546)
(socket_to_fd): Add assertion against indexing fd_info[] with a
value that is out of bounds.
(sys_accept): If fd is negative, do not set up the child_process
structure for reading.
modified:
src/ChangeLog
src/w32.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2013-02-14 22:08:38 +0000
+++ b/src/ChangeLog 2013-02-15 09:01:13 +0000
@@ -1,3 +1,15 @@
+2013-02-15 Eli Zaretskii <address@hidden>
+
+ * w32.c (sys_socket, sys_bind, sys_connect, sys_gethostname)
+ (sys_gethostbyname, sys_getservbyname, sys_getpeername)
+ (sys_shutdown, sys_setsockopt, sys_listen, sys_getsockname)
+ (sys_accept, sys_recvfrom, sys_sendto, fcntl): In case of failure,
+ make sure errno is set to an appropriate value. (Bug#13546)
+ (socket_to_fd): Add assertion against indexing fd_info[] with a
+ value that is out of bounds.
+ (sys_accept): If fd is negative, do not set up the child_process
+ structure for reading.
+
2013-02-14 Paul Eggert <address@hidden>
Backport GCPRO fix from trunk (Bug#13650).
=== modified file 'src/w32.c'
--- a/src/w32.c 2013-02-13 17:00:26 +0000
+++ b/src/w32.c 2013-02-15 09:01:13 +0000
@@ -5655,7 +5655,7 @@
if (winsock_lib == NULL)
{
- h_errno = ENETDOWN;
+ errno = h_errno = ENETDOWN;
return INVALID_SOCKET;
}
@@ -5665,7 +5665,13 @@
s = pfn_socket (af, type, protocol);
if (s != INVALID_SOCKET)
- return socket_to_fd (s);
+ {
+ int retval = socket_to_fd (s);
+
+ if (retval == -1)
+ errno = h_errno;
+ return retval;
+ }
set_errno ();
return -1;
@@ -5732,6 +5738,7 @@
}
}
}
+ eassert (fd < MAXDESC);
fd_info[fd].hnd = (HANDLE) s;
/* set our own internal flags */
@@ -5770,7 +5777,7 @@
{
if (winsock_lib == NULL)
{
- h_errno = ENOTSOCK;
+ errno = h_errno = ENOTSOCK;
return SOCKET_ERROR;
}
@@ -5782,7 +5789,7 @@
set_errno ();
return rc;
}
- h_errno = ENOTSOCK;
+ errno = h_errno = ENOTSOCK;
return SOCKET_ERROR;
}
@@ -5791,7 +5798,7 @@
{
if (winsock_lib == NULL)
{
- h_errno = ENOTSOCK;
+ errno = h_errno = ENOTSOCK;
return SOCKET_ERROR;
}
@@ -5803,7 +5810,7 @@
set_errno ();
return rc;
}
- h_errno = ENOTSOCK;
+ errno = h_errno = ENOTSOCK;
return SOCKET_ERROR;
}
@@ -5837,7 +5844,7 @@
if (namelen > MAX_COMPUTERNAME_LENGTH)
return !GetComputerName (name, (DWORD *)&namelen);
- h_errno = EFAULT;
+ errno = h_errno = EFAULT;
return SOCKET_ERROR;
}
@@ -5848,7 +5855,7 @@
if (winsock_lib == NULL)
{
- h_errno = ENETDOWN;
+ errno = h_errno = ENETDOWN;
return NULL;
}
@@ -5866,7 +5873,7 @@
if (winsock_lib == NULL)
{
- h_errno = ENETDOWN;
+ errno = h_errno = ENETDOWN;
return NULL;
}
@@ -5882,7 +5889,7 @@
{
if (winsock_lib == NULL)
{
- h_errno = ENETDOWN;
+ errno = h_errno = ENETDOWN;
return SOCKET_ERROR;
}
@@ -5894,7 +5901,7 @@
set_errno ();
return rc;
}
- h_errno = ENOTSOCK;
+ errno = h_errno = ENOTSOCK;
return SOCKET_ERROR;
}
@@ -5903,7 +5910,7 @@
{
if (winsock_lib == NULL)
{
- h_errno = ENETDOWN;
+ errno = h_errno = ENETDOWN;
return SOCKET_ERROR;
}
@@ -5915,7 +5922,7 @@
set_errno ();
return rc;
}
- h_errno = ENOTSOCK;
+ errno = h_errno = ENOTSOCK;
return SOCKET_ERROR;
}
@@ -5924,7 +5931,7 @@
{
if (winsock_lib == NULL)
{
- h_errno = ENETDOWN;
+ errno = h_errno = ENETDOWN;
return SOCKET_ERROR;
}
@@ -5937,7 +5944,7 @@
set_errno ();
return rc;
}
- h_errno = ENOTSOCK;
+ errno = h_errno = ENOTSOCK;
return SOCKET_ERROR;
}
@@ -5946,7 +5953,7 @@
{
if (winsock_lib == NULL)
{
- h_errno = ENETDOWN;
+ errno = h_errno = ENETDOWN;
return SOCKET_ERROR;
}
@@ -5960,7 +5967,7 @@
fd_info[s].flags |= FILE_LISTEN;
return rc;
}
- h_errno = ENOTSOCK;
+ errno = h_errno = ENOTSOCK;
return SOCKET_ERROR;
}
@@ -5969,7 +5976,7 @@
{
if (winsock_lib == NULL)
{
- h_errno = ENETDOWN;
+ errno = h_errno = ENETDOWN;
return SOCKET_ERROR;
}
@@ -5981,7 +5988,7 @@
set_errno ();
return rc;
}
- h_errno = ENOTSOCK;
+ errno = h_errno = ENOTSOCK;
return SOCKET_ERROR;
}
@@ -5990,7 +5997,7 @@
{
if (winsock_lib == NULL)
{
- h_errno = ENETDOWN;
+ errno = h_errno = ENETDOWN;
return -1;
}
@@ -6002,13 +6009,20 @@
if (t == INVALID_SOCKET)
set_errno ();
else
- fd = socket_to_fd (t);
+ {
+ fd = socket_to_fd (t);
+ if (fd < 0)
+ errno = h_errno; /* socket_to_fd sets h_errno */
+ }
- fd_info[s].cp->status = STATUS_READ_ACKNOWLEDGED;
- ResetEvent (fd_info[s].cp->char_avail);
+ if (fd >= 0)
+ {
+ fd_info[s].cp->status = STATUS_READ_ACKNOWLEDGED;
+ ResetEvent (fd_info[s].cp->char_avail);
+ }
return fd;
}
- h_errno = ENOTSOCK;
+ errno = h_errno = ENOTSOCK;
return -1;
}
@@ -6018,7 +6032,7 @@
{
if (winsock_lib == NULL)
{
- h_errno = ENETDOWN;
+ errno = h_errno = ENETDOWN;
return SOCKET_ERROR;
}
@@ -6030,7 +6044,7 @@
set_errno ();
return rc;
}
- h_errno = ENOTSOCK;
+ errno = h_errno = ENOTSOCK;
return SOCKET_ERROR;
}
@@ -6040,7 +6054,7 @@
{
if (winsock_lib == NULL)
{
- h_errno = ENETDOWN;
+ errno = h_errno = ENETDOWN;
return SOCKET_ERROR;
}
@@ -6052,7 +6066,7 @@
set_errno ();
return rc;
}
- h_errno = ENOTSOCK;
+ errno = h_errno = ENOTSOCK;
return SOCKET_ERROR;
}
@@ -6063,7 +6077,7 @@
{
if (winsock_lib == NULL)
{
- h_errno = ENETDOWN;
+ errno = h_errno = ENETDOWN;
return -1;
}
@@ -6086,7 +6100,7 @@
return SOCKET_ERROR;
}
}
- h_errno = ENOTSOCK;
+ errno = h_errno = ENOTSOCK;
return SOCKET_ERROR;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/emacs-24 r111267: Improve error reporting as part of solving bug #13546 on MS-Windows.,
Eli Zaretskii <=