From 5d3f7a688518f805fb776c64ef6b4494147bfbbe Mon Sep 17 00:00:00 2001 From: Rein Klazes Date: Tue, 7 Mar 2000 12:23:51 +0000 Subject: [PATCH] Add a message and fix error code if __ws_getservbyname() and __ws_getservbyport() cannot find the requested service. Fix WINSOCK_setsockopt() when called with optval pointing to 16 bit int. --- dlls/winsock/socket.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/dlls/winsock/socket.c b/dlls/winsock/socket.c index 50ab13786d3..e821e8a613d 100644 --- a/dlls/winsock/socket.c +++ b/dlls/winsock/socket.c @@ -1638,6 +1638,7 @@ INT WINAPI WINSOCK_setsockopt(SOCKET16 s, INT level, INT optname, { struct linger linger; int fd = _get_sock_fd(s); + int woptval; if(optname == WS_SO_DONTLINGER) { linger.l_onoff = *((int*)optval) ? 0: 1; @@ -1655,6 +1656,10 @@ INT WINAPI WINSOCK_setsockopt(SOCKET16 s, INT level, INT optname, is null?? */ optval = (char*)&linger; optlen = sizeof(struct linger); + } else if (optlen < sizeof(int)){ + woptval= *((INT16 *) optval); + optval= (char*) &woptval; + optlen=sizeof(int); } } if (setsockopt(fd, level, optname, optval, optlen) == 0) @@ -1994,9 +1999,14 @@ struct WIN_servent* __ws_getservbyname(const char *name, const char *proto, int if( WS_dup_se(pwsi, serv, dup_flag) ) return (struct WIN_servent*)(pwsi->se); else SetLastError(WSAENOBUFS); - else SetLastError((h_errno < 0) ? wsaErrno() : wsaHerrno()); + else { + MESSAGE("service %s protocol %s not found; maybe you have add " + "this to /etc/services\n", debugstr_a(pwsi->buffer), + debugstr_a(pwsi->buffer+i)); + SetLastError(WSANO_DATA); + } else SetLastError(WSAENOBUFS); - } + } else SetLastError(WSANOTINITIALISED); return NULL; } @@ -2034,9 +2044,14 @@ static struct WIN_servent* __ws_getservbyport(int port, const char* proto, int d if( WS_dup_se(pwsi, serv, dup_flag) ) return (struct WIN_servent*)(pwsi->se); else SetLastError(WSAENOBUFS); - else SetLastError((h_errno < 0) ? wsaErrno() : wsaHerrno()); + else { + MESSAGE("service on port %d protocol %s not found; maybe you have " + "add this to /etc/services\n", ntohl(port), + debugstr_a(pwsi->buffer)); + SetLastError(WSANO_DATA); + } else SetLastError(WSAENOBUFS); - } + } else SetLastError(WSANOTINITIALISED); return NULL; } -- 2.11.4.GIT