Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
f4742909
Commit
f4742909
authored
10 years ago
by
Guillaume Roguez
Browse files
Options
Downloads
Patches
Plain Diff
ice: prevent nullptr access to non-initalized transport
Refs #72663 Change-Id: Ic3e5f60ce14e55957fafd738df40bc811c5baac9
parent
2e9bcc05
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/ice_transport.cpp
+20
-6
20 additions, 6 deletions
src/ice_transport.cpp
with
20 additions
and
6 deletions
src/ice_transport.cpp
+
20
−
6
View file @
f4742909
...
@@ -257,6 +257,11 @@ bool
...
@@ -257,6 +257,11 @@ bool
IceTransport
::
start
(
const
Attribute
&
rem_attrs
,
IceTransport
::
start
(
const
Attribute
&
rem_attrs
,
const
std
::
vector
<
IceCandidate
>&
rem_candidates
)
const
std
::
vector
<
IceCandidate
>&
rem_candidates
)
{
{
if
(
not
isInitialized
())
{
RING_ERR
(
"ICE: not initialized transport"
);
return
false
;
}
// pj_ice_strans_start_ice crashes if remote candidates array is empty
// pj_ice_strans_start_ice crashes if remote candidates array is empty
if
(
rem_candidates
.
empty
())
{
if
(
rem_candidates
.
empty
())
{
RING_ERR
(
"ICE start failed: no remote candidates"
);
RING_ERR
(
"ICE start failed: no remote candidates"
);
...
@@ -334,7 +339,7 @@ IceTransport::start(const std::vector<uint8_t>& rem_data)
...
@@ -334,7 +339,7 @@ IceTransport::start(const std::vector<uint8_t>& rem_data)
bool
bool
IceTransport
::
stop
()
IceTransport
::
stop
()
{
{
if
(
not
pj_ice_strans_has_sess
(
icest_
.
get
()
))
{
if
(
not
isInitialized
(
))
{
RING_ERR
(
"Session not created yet"
);
RING_ERR
(
"Session not created yet"
);
return
false
;
return
false
;
}
}
...
@@ -352,7 +357,9 @@ IceTransport::stop()
...
@@ -352,7 +357,9 @@ IceTransport::stop()
bool
bool
IceTransport
::
isInitialized
()
const
IceTransport
::
isInitialized
()
const
{
{
return
pj_ice_strans_has_sess
(
icest_
.
get
());
if
(
auto
icest
=
icest_
.
get
())
return
pj_ice_strans_has_sess
(
icest
);
return
false
;
}
}
bool
bool
...
@@ -370,13 +377,13 @@ IceTransport::isCompleted() const
...
@@ -370,13 +377,13 @@ IceTransport::isCompleted() const
bool
bool
IceTransport
::
isRunning
()
const
IceTransport
::
isRunning
()
const
{
{
return
pj_ice_strans_get_state
(
icest_
.
get
())
==
PJ_ICE_STRANS_STATE_RUNNING
;
return
isInitialized
()
and
pj_ice_strans_get_state
(
icest_
.
get
())
==
PJ_ICE_STRANS_STATE_RUNNING
;
}
}
bool
bool
IceTransport
::
isFailed
()
const
IceTransport
::
isFailed
()
const
{
{
return
pj_ice_strans_get_state
(
icest_
.
get
())
==
PJ_ICE_STRANS_STATE_FAILED
;
return
isInitialized
()
and
pj_ice_strans_get_state
(
icest_
.
get
())
==
PJ_ICE_STRANS_STATE_FAILED
;
}
}
IpAddr
IpAddr
...
@@ -390,8 +397,10 @@ IceTransport::getLocalAddress(unsigned comp_id) const
...
@@ -390,8 +397,10 @@ IceTransport::getLocalAddress(unsigned comp_id) const
IpAddr
IpAddr
IceTransport
::
getRemoteAddress
(
unsigned
comp_id
)
const
IceTransport
::
getRemoteAddress
(
unsigned
comp_id
)
const
{
{
if
(
isInitialized
())
{
if
(
auto
sess
=
pj_ice_strans_get_valid_pair
(
icest_
.
get
(),
comp_id
+
1
))
if
(
auto
sess
=
pj_ice_strans_get_valid_pair
(
icest_
.
get
(),
comp_id
+
1
))
return
sess
->
rcand
->
addr
;
return
sess
->
rcand
->
addr
;
}
return
{};
return
{};
}
}
...
@@ -651,6 +660,11 @@ IceTransport::setOnRecv(unsigned comp_id, IceRecvCb cb)
...
@@ -651,6 +660,11 @@ IceTransport::setOnRecv(unsigned comp_id, IceRecvCb cb)
ssize_t
ssize_t
IceTransport
::
send
(
int
comp_id
,
const
unsigned
char
*
buf
,
size_t
len
)
IceTransport
::
send
(
int
comp_id
,
const
unsigned
char
*
buf
,
size_t
len
)
{
{
if
(
not
isInitialized
())
{
RING_ERR
(
"ICE: not initialized transport"
);
return
-
1
;
}
register_thread
();
register_thread
();
auto
remote
=
getRemoteAddress
(
comp_id
);
auto
remote
=
getRemoteAddress
(
comp_id
);
if
(
!
remote
)
{
if
(
!
remote
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment