Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stunserver
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Stunserver
Commits
ec577883
Commit
ec577883
authored
Sep 21, 2011
by
John Selbie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix potential crashing bug in adapter enumeration code
parent
d9fcc3f9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
4 deletions
+5
-4
networkutils/adapters.cpp
networkutils/adapters.cpp
+4
-3
server/main.cpp
server/main.cpp
+1
-1
No files found.
networkutils/adapters.cpp
View file @
ec577883
...
@@ -31,7 +31,7 @@ void GetDefaultAdapters(int family, ifaddrs* pList, ifaddrs** ppAddrPrimary, ifa
...
@@ -31,7 +31,7 @@ void GetDefaultAdapters(int family, ifaddrs* pList, ifaddrs** ppAddrPrimary, ifa
pAdapter
=
pList
;
pAdapter
=
pList
;
while
(
pAdapter
)
while
(
pAdapter
)
{
{
if
(
(
pAdapter
->
ifa_addr
->
sa_family
==
family
)
&&
(
pAdapter
->
ifa_flags
&
IFF_UP
)
&&
!
(
pAdapter
->
ifa_flags
&
IFF_LOOPBACK
))
if
(
(
pAdapter
->
ifa_addr
!=
NULL
)
&&
(
pAdapter
->
ifa_addr
->
sa_family
==
family
)
&&
(
pAdapter
->
ifa_flags
&
IFF_UP
)
&&
!
(
pAdapter
->
ifa_flags
&
IFF_LOOPBACK
))
{
{
if
(
*
ppAddrPrimary
==
NULL
)
if
(
*
ppAddrPrimary
==
NULL
)
{
{
...
@@ -97,6 +97,7 @@ HRESULT GetBestAddressForSocketBind(bool fPrimary, int family, uint16_t port, CS
...
@@ -97,6 +97,7 @@ HRESULT GetBestAddressForSocketBind(bool fPrimary, int family, uint16_t port, CS
pAdapter
=
fPrimary
?
pAdapter1
:
pAdapter2
;
pAdapter
=
fPrimary
?
pAdapter1
:
pAdapter2
;
ChkIf
(
pAdapter
==
NULL
,
E_FAIL
);
ChkIf
(
pAdapter
==
NULL
,
E_FAIL
);
ChkIfA
(
pAdapter
->
ifa_addr
==
NULL
,
E_UNEXPECTED
);
*
pSocketAddr
=
CSocketAddress
(
*
pAdapter
->
ifa_addr
);
*
pSocketAddr
=
CSocketAddress
(
*
pAdapter
->
ifa_addr
);
pSocketAddr
->
SetPort
(
port
);
pSocketAddr
->
SetPort
(
port
);
...
@@ -126,7 +127,7 @@ HRESULT GetSocketAddressForAdapter(int family, const char* pszAdapterName, uint1
...
@@ -126,7 +127,7 @@ HRESULT GetSocketAddressForAdapter(int family, const char* pszAdapterName, uint1
pAdapter
=
pList
;
pAdapter
=
pList
;
while
(
pAdapter
)
while
(
pAdapter
)
{
{
if
(
family
==
pAdapter
->
ifa_addr
->
sa_family
)
if
(
(
pAdapter
->
ifa_addr
!=
NULL
)
&&
(
pAdapter
->
ifa_name
!=
NULL
)
&&
(
family
==
pAdapter
->
ifa_addr
->
sa_family
)
)
{
{
if
(
strcmp
(
pAdapter
->
ifa_name
,
pszAdapterName
)
==
0
)
if
(
strcmp
(
pAdapter
->
ifa_name
,
pszAdapterName
)
==
0
)
{
{
...
@@ -153,7 +154,7 @@ HRESULT GetSocketAddressForAdapter(int family, const char* pszAdapterName, uint1
...
@@ -153,7 +154,7 @@ HRESULT GetSocketAddressForAdapter(int family, const char* pszAdapterName, uint1
pAdapter
=
pList
;
pAdapter
=
pList
;
while
(
pAdapter
)
while
(
pAdapter
)
{
{
if
(
family
==
pAdapter
->
ifa_addr
->
sa_family
)
if
(
(
pAdapter
->
ifa_addr
!=
NULL
)
&&
(
family
==
pAdapter
->
ifa_addr
->
sa_family
)
)
{
{
// offsetof(sockaddr_in, sin_addr) != offsetof(sockaddr_in6, sin6_addr)
// offsetof(sockaddr_in, sin_addr) != offsetof(sockaddr_in6, sin6_addr)
// so you really can't do too many casting tricks like you can with sockaddr and sockaddr_in
// so you really can't do too many casting tricks like you can with sockaddr and sockaddr_in
...
...
server/main.cpp
View file @
ec577883
...
@@ -473,7 +473,7 @@ int main(int argc, char** argv)
...
@@ -473,7 +473,7 @@ int main(int argc, char** argv)
if
(
FAILED
(
hr
))
if
(
FAILED
(
hr
))
{
{
Logging
::
LogMsg
(
LL_ALWAYS
,
"Error building configuraton from command line options"
);
Logging
::
LogMsg
(
LL_ALWAYS
,
"Error building configurat
i
on from command line options"
);
PrintUsage
(
true
);
PrintUsage
(
true
);
return
-
3
;
return
-
3
;
}
}
...
...
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