mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 13:26:17 +00:00
[WS2_32]
- Correctly handle port 0 in getaddrinfo - Stub numeric port case of getnameinfo svn path=/trunk/; revision=63632
This commit is contained in:
parent
6582b51c46
commit
1fd39b3a08
2 changed files with 14 additions and 2 deletions
|
@ -1596,6 +1596,7 @@ getaddrinfo(const char FAR * nodename,
|
||||||
struct addrinfo *ret = NULL, *ai;
|
struct addrinfo *ret = NULL, *ai;
|
||||||
ULONG addr;
|
ULONG addr;
|
||||||
USHORT port;
|
USHORT port;
|
||||||
|
PCHAR pc;
|
||||||
struct servent *se;
|
struct servent *se;
|
||||||
char *proto;
|
char *proto;
|
||||||
LPPROTOENT pent;
|
LPPROTOENT pent;
|
||||||
|
@ -1624,9 +1625,9 @@ getaddrinfo(const char FAR * nodename,
|
||||||
if (servname)
|
if (servname)
|
||||||
{
|
{
|
||||||
/* converting port number */
|
/* converting port number */
|
||||||
port = strtoul(servname, NULL, 10);
|
port = strtoul(servname, &pc, 10);
|
||||||
/* service name was specified? */
|
/* service name was specified? */
|
||||||
if (port == 0)
|
if (*pc != ANSI_NULL)
|
||||||
{
|
{
|
||||||
/* protocol was specified? */
|
/* protocol was specified? */
|
||||||
if (hints && hints->ai_protocol)
|
if (hints && hints->ai_protocol)
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "ws2_32.h"
|
#include "ws2_32.h"
|
||||||
|
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
|
#include <strsafe.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
|
@ -895,6 +896,16 @@ getnameinfo(const struct sockaddr FAR * sa,
|
||||||
DWORD servlen,
|
DWORD servlen,
|
||||||
INT flags)
|
INT flags)
|
||||||
{
|
{
|
||||||
|
if (!host && serv && flags & NI_NUMERICSERV)
|
||||||
|
{
|
||||||
|
const struct sockaddr_in *sa_in = (const struct sockaddr_in *)sa;
|
||||||
|
if (salen >= sizeof(*sa_in) && sa->sa_family == AF_INET)
|
||||||
|
{
|
||||||
|
StringCbPrintfA(serv, servlen, "%u", sa_in->sin_port);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UNIMPLEMENTED
|
UNIMPLEMENTED
|
||||||
|
|
||||||
WSASetLastError(WSASYSCALLFAILURE);
|
WSASetLastError(WSASYSCALLFAILURE);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue