Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
18a02d8f
Commit
18a02d8f
authored
Sep 08, 2015
by
Bruno Jesus
Committed by
Alexandre Julliard
Sep 08, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ws2_32: Try harder to get the host name address in getaddrinfo.
parent
614afcef
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
5 deletions
+68
-5
socket.c
dlls/ws2_32/socket.c
+13
-5
sock.c
dlls/ws2_32/tests/sock.c
+55
-0
No files found.
dlls/ws2_32/socket.c
View file @
18a02d8f
...
...
@@ -5996,7 +5996,7 @@ int WINAPI WS_getaddrinfo(LPCSTR nodename, LPCSTR servname, const struct WS_addr
struct
addrinfo
*
unixaires
=
NULL
;
int
result
;
struct
addrinfo
unixhints
,
*
punixhints
=
NULL
;
char
*
hostname
=
NULL
;
char
*
hostname
;
const
char
*
node
;
*
res
=
NULL
;
...
...
@@ -6006,13 +6006,13 @@ int WINAPI WS_getaddrinfo(LPCSTR nodename, LPCSTR servname, const struct WS_addr
return
WSAHOST_NOT_FOUND
;
}
hostname
=
get_hostname
();
if
(
!
hostname
)
return
WSA_NOT_ENOUGH_MEMORY
;
if
(
!
nodename
)
node
=
NULL
;
else
if
(
!
nodename
[
0
])
{
node
=
hostname
=
get_hostname
();
if
(
!
node
)
return
WSA_NOT_ENOUGH_MEMORY
;
}
node
=
hostname
;
else
node
=
nodename
;
...
...
@@ -6056,6 +6056,14 @@ int WINAPI WS_getaddrinfo(LPCSTR nodename, LPCSTR servname, const struct WS_addr
/* getaddrinfo(3) is thread safe, no need to wrap in CS */
result
=
getaddrinfo
(
node
,
servname
,
punixhints
,
&
unixaires
);
if
(
result
&&
!
strcmp
(
hostname
,
node
))
{
/* If it didn't work it means the host name IP is not in /etc/hosts, try again
* by sending a NULL host and avoid sending a NULL servname too because that
* is invalid */
ERR_
(
winediag
)(
"Failed to resolve your host name IP
\n
"
);
result
=
getaddrinfo
(
NULL
,
servname
?
servname
:
"0"
,
punixhints
,
&
unixaires
);
}
TRACE
(
"%s, %s %p -> %p %d
\n
"
,
debugstr_a
(
nodename
),
debugstr_a
(
servname
),
hints
,
res
,
result
);
HeapFree
(
GetProcessHeap
(),
0
,
hostname
);
...
...
dlls/ws2_32/tests/sock.c
View file @
18a02d8f
...
...
@@ -6313,6 +6313,8 @@ static void test_GetAddrInfoW(void)
static
const
WCHAR
zero
[]
=
{
'0'
,
0
};
int
i
,
ret
;
ADDRINFOW
*
result
,
*
result2
,
*
p
,
hint
;
WCHAR
name
[
256
];
DWORD
size
=
sizeof
(
name
);
if
(
!
pGetAddrInfoW
||
!
pFreeAddrInfoW
)
{
...
...
@@ -6320,6 +6322,8 @@ static void test_GetAddrInfoW(void)
return
;
}
memset
(
&
hint
,
0
,
sizeof
(
ADDRINFOW
));
name
[
0
]
=
0
;
GetComputerNameExW
(
ComputerNamePhysicalDnsHostname
,
name
,
&
size
);
result
=
(
ADDRINFOW
*
)
0xdeadbeef
;
WSASetLastError
(
0xdeadbeef
);
...
...
@@ -6395,6 +6399,30 @@ static void test_GetAddrInfoW(void)
ok
(
WSAGetLastError
()
==
0
,
"expected 0, got %d
\n
"
,
WSAGetLastError
());
pFreeAddrInfoW
(
result
);
/* try to get information from the computer name, result is the same
* as if requesting with an empty host name. */
ret
=
pGetAddrInfoW
(
name
,
NULL
,
NULL
,
&
result
);
ok
(
!
ret
,
"GetAddrInfoW failed with %d
\n
"
,
WSAGetLastError
());
ok
(
result
!=
NULL
,
"GetAddrInfoW failed
\n
"
);
ret
=
pGetAddrInfoW
(
empty
,
NULL
,
NULL
,
&
result2
);
ok
(
!
ret
,
"GetAddrInfoW failed with %d
\n
"
,
WSAGetLastError
());
ok
(
result
!=
NULL
,
"GetAddrInfoW failed
\n
"
);
compare_addrinfow
(
result
,
result2
);
pFreeAddrInfoW
(
result
);
pFreeAddrInfoW
(
result2
);
ret
=
pGetAddrInfoW
(
name
,
empty
,
NULL
,
&
result
);
ok
(
!
ret
,
"GetAddrInfoW failed with %d
\n
"
,
WSAGetLastError
());
ok
(
result
!=
NULL
,
"GetAddrInfoW failed
\n
"
);
ret
=
pGetAddrInfoW
(
empty
,
empty
,
NULL
,
&
result2
);
ok
(
!
ret
,
"GetAddrInfoW failed with %d
\n
"
,
WSAGetLastError
());
ok
(
result
!=
NULL
,
"GetAddrInfoW failed
\n
"
);
compare_addrinfow
(
result
,
result2
);
pFreeAddrInfoW
(
result
);
pFreeAddrInfoW
(
result2
);
result
=
(
ADDRINFOW
*
)
0xdeadbeef
;
WSASetLastError
(
0xdeadbeef
);
ret
=
pGetAddrInfoW
(
NULL
,
NULL
,
NULL
,
&
result
);
...
...
@@ -6475,6 +6503,8 @@ static void test_getaddrinfo(void)
{
int
i
,
ret
;
ADDRINFOA
*
result
,
*
result2
,
*
p
,
hint
;
CHAR
name
[
256
];
DWORD
size
=
sizeof
(
name
);
if
(
!
pgetaddrinfo
||
!
pfreeaddrinfo
)
{
...
...
@@ -6482,6 +6512,7 @@ static void test_getaddrinfo(void)
return
;
}
memset
(
&
hint
,
0
,
sizeof
(
ADDRINFOA
));
GetComputerNameExA
(
ComputerNamePhysicalDnsHostname
,
name
,
&
size
);
result
=
(
ADDRINFOA
*
)
0xdeadbeef
;
WSASetLastError
(
0xdeadbeef
);
...
...
@@ -6558,6 +6589,30 @@ static void test_getaddrinfo(void)
ok
(
WSAGetLastError
()
==
0
,
"expected 0, got %d
\n
"
,
WSAGetLastError
());
pfreeaddrinfo
(
result
);
/* try to get information from the computer name, result is the same
* as if requesting with an empty host name. */
ret
=
pgetaddrinfo
(
name
,
NULL
,
NULL
,
&
result
);
ok
(
!
ret
,
"getaddrinfo failed with %d
\n
"
,
WSAGetLastError
());
ok
(
result
!=
NULL
,
"GetAddrInfoW failed
\n
"
);
ret
=
pgetaddrinfo
(
""
,
NULL
,
NULL
,
&
result2
);
ok
(
!
ret
,
"getaddrinfo failed with %d
\n
"
,
WSAGetLastError
());
ok
(
result
!=
NULL
,
"GetAddrInfoW failed
\n
"
);
compare_addrinfo
(
result
,
result2
);
pfreeaddrinfo
(
result
);
pfreeaddrinfo
(
result2
);
ret
=
pgetaddrinfo
(
name
,
""
,
NULL
,
&
result
);
ok
(
!
ret
,
"getaddrinfo failed with %d
\n
"
,
WSAGetLastError
());
ok
(
result
!=
NULL
,
"GetAddrInfoW failed
\n
"
);
ret
=
pgetaddrinfo
(
""
,
""
,
NULL
,
&
result2
);
ok
(
!
ret
,
"getaddrinfo failed with %d
\n
"
,
WSAGetLastError
());
ok
(
result
!=
NULL
,
"GetAddrInfoW failed
\n
"
);
compare_addrinfo
(
result
,
result2
);
pfreeaddrinfo
(
result
);
pfreeaddrinfo
(
result2
);
result
=
(
ADDRINFOA
*
)
0xdeadbeef
;
WSASetLastError
(
0xdeadbeef
);
ret
=
pgetaddrinfo
(
"nxdomain.codeweavers.com"
,
NULL
,
NULL
,
&
result
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment