Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
f3b64f95
Commit
f3b64f95
authored
Apr 12, 2020
by
Stefan Dösinger
Committed by
Alexandre Julliard
Apr 22, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
iphlpapi: Honor sa_len when reading AF_INET addresses.
Signed-off-by:
Stefan Dösinger
<
stefan@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
4932eec3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
25 deletions
+27
-25
ipstats.c
dlls/iphlpapi/ipstats.c
+27
-25
No files found.
dlls/iphlpapi/ipstats.c
View file @
f3b64f95
...
...
@@ -1548,33 +1548,35 @@ DWORD WINAPI AllocateAndGetIpForwardTableFromStack(PMIB_IPFORWARDTABLE *ppIpForw
ADVANCE
(
addrPtr
,
sa
);
/* default routes are encoded by length-zero sockaddr */
if
(
sa
->
sa_len
==
0
)
{
addr
=
0
;
}
else
{
/* Apple's netstat prints the netmask together with the destination
* and only looks at the destination's address family. The netmask's
* sa_family sometimes contains the non-existent value 0xff. */
switch
(
i
==
RTA_NETMASK
?
dst_family
:
sa
->
sa_family
)
{
case
AF_INET
:
{
struct
sockaddr_in
*
sin
=
(
struct
sockaddr_in
*
)
sa
;
addr
=
sin
->
sin_addr
.
s_addr
;
break
;
}
/* Apple's netstat prints the netmask together with the destination
* and only looks at the destination's address family. The netmask's
* sa_family sometimes contains the non-existent value 0xff. */
switch
(
i
==
RTA_NETMASK
?
dst_family
:
sa
->
sa_family
)
{
case
AF_INET
:
{
/* Netmasks (and possibly other addresses) have only enough size
* to represent the non-zero bits, e.g. a netmask of 255.0.0.0 has
* 5 bytes (1 sa_len, 1 sa_family, 2 sa_port and 1 for the first
* byte of sin_addr). Due to the alignment constraint we can de
* facto read the full 4 bytes of sin_addr (except for the case of
* netmask 0). Don't assume though that the extra bytes are zeroed. */
struct
sockaddr_in
sin
=
{
0
};
memcpy
(
&
sin
,
sa
,
sa
->
sa_len
);
addr
=
sin
.
sin_addr
.
s_addr
;
break
;
}
#ifdef AF_LINK
case
AF_LINK
:
if
(
i
==
RTA_GATEWAY
&&
row
.
u1
.
ForwardType
==
MIB_IPROUTE_TYPE_DIRECT
)
{
/* For direct route we may simply use dest addr as next hop */
C_ASSERT
(
RTA_DST
<
RTA_GATEWAY
);
addr
=
row
.
dwForwardDest
;
break
;
}
/* fallthrough */
#endif
default:
WARN
(
"Received unsupported sockaddr family 0x%x
\n
"
,
sa
->
sa_family
);
addr
=
0
;
case
AF_LINK
:
if
(
i
==
RTA_GATEWAY
&&
row
.
u1
.
ForwardType
==
MIB_IPROUTE_TYPE_DIRECT
)
{
/* For direct route we may simply use dest addr as next hop */
C_ASSERT
(
RTA_DST
<
RTA_GATEWAY
);
addr
=
row
.
dwForwardDest
;
break
;
}
/* fallthrough */
#endif
default:
WARN
(
"Received unsupported sockaddr family 0x%x
\n
"
,
sa
->
sa_family
);
addr
=
0
;
}
switch
(
i
)
...
...
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