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
f68dd14e
Commit
f68dd14e
authored
4 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
tls_session: protect session in send()
Change-Id: I7b87bad47c66bda0d66140b59315ea45a43a4839
parent
0a133999
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/security/tls_session.cpp
+6
-8
6 additions, 8 deletions
src/security/tls_session.cpp
with
6 additions
and
8 deletions
src/security/tls_session.cpp
+
6
−
8
View file @
f68dd14e
...
@@ -283,7 +283,8 @@ public:
...
@@ -283,7 +283,8 @@ public:
std
::
unique_ptr
<
TlsAnonymousClientCredendials
>
cacred_
;
// ctor init.
std
::
unique_ptr
<
TlsAnonymousClientCredendials
>
cacred_
;
// ctor init.
std
::
unique_ptr
<
TlsAnonymousServerCredendials
>
sacred_
;
// ctor init.
std
::
unique_ptr
<
TlsAnonymousServerCredendials
>
sacred_
;
// ctor init.
std
::
unique_ptr
<
TlsCertificateCredendials
>
xcred_
;
// ctor init.
std
::
unique_ptr
<
TlsCertificateCredendials
>
xcred_
;
// ctor init.
std
::
mutex
sessionMutex_
;
std
::
mutex
sessionReadMutex_
;
std
::
mutex
sessionWriteMutex_
;
gnutls_session_t
session_
{
nullptr
};
gnutls_session_t
session_
{
nullptr
};
gnutls_datum_t
cookie_key_
{
nullptr
,
0
};
gnutls_datum_t
cookie_key_
{
nullptr
,
0
};
gnutls_dtls_prestate_st
prestate_
{};
gnutls_dtls_prestate_st
prestate_
{};
...
@@ -832,6 +833,7 @@ TlsSession::TlsSessionImpl::sendOcspRequest(const std::string& uri,
...
@@ -832,6 +833,7 @@ TlsSession::TlsSessionImpl::sendOcspRequest(const std::string& uri,
std
::
size_t
std
::
size_t
TlsSession
::
TlsSessionImpl
::
send
(
const
ValueType
*
tx_data
,
std
::
size_t
tx_size
,
std
::
error_code
&
ec
)
TlsSession
::
TlsSessionImpl
::
send
(
const
ValueType
*
tx_data
,
std
::
size_t
tx_size
,
std
::
error_code
&
ec
)
{
{
std
::
lock_guard
<
std
::
mutex
>
lk
(
sessionWriteMutex_
);
if
(
state_
!=
TlsSessionState
::
ESTABLISHED
)
{
if
(
state_
!=
TlsSessionState
::
ESTABLISHED
)
{
ec
=
std
::
error_code
(
GNUTLS_E_INVALID_SESSION
,
std
::
system_category
());
ec
=
std
::
error_code
(
GNUTLS_E_INVALID_SESSION
,
std
::
system_category
());
return
0
;
return
0
;
...
@@ -1039,7 +1041,8 @@ TlsSession::TlsSessionImpl::cleanup()
...
@@ -1039,7 +1041,8 @@ TlsSession::TlsSessionImpl::cleanup()
stateCondition_
.
notify_all
();
stateCondition_
.
notify_all
();
{
{
std
::
lock_guard
<
std
::
mutex
>
lk
(
sessionMutex_
);
std
::
lock_guard
<
std
::
mutex
>
lk1
(
sessionReadMutex_
);
std
::
lock_guard
<
std
::
mutex
>
lk2
(
sessionWriteMutex_
);
if
(
session_
)
{
if
(
session_
)
{
if
(
transport_
->
isReliable
())
if
(
transport_
->
isReliable
())
gnutls_bye
(
session_
,
GNUTLS_SHUT_RDWR
);
gnutls_bye
(
session_
,
GNUTLS_SHUT_RDWR
);
...
@@ -1624,11 +1627,6 @@ TlsSession::shutdown()
...
@@ -1624,11 +1627,6 @@ TlsSession::shutdown()
std
::
size_t
std
::
size_t
TlsSession
::
write
(
const
ValueType
*
data
,
std
::
size_t
size
,
std
::
error_code
&
ec
)
TlsSession
::
write
(
const
ValueType
*
data
,
std
::
size_t
size
,
std
::
error_code
&
ec
)
{
{
if
(
pimpl_
->
state_
!=
TlsSessionState
::
ESTABLISHED
)
{
ec
=
std
::
make_error_code
(
std
::
errc
::
broken_pipe
);
return
0
;
}
return
pimpl_
->
send
(
data
,
size
,
ec
);
return
pimpl_
->
send
(
data
,
size
,
ec
);
}
}
...
@@ -1645,7 +1643,7 @@ TlsSession::read(ValueType* data, std::size_t size, std::error_code& ec)
...
@@ -1645,7 +1643,7 @@ TlsSession::read(ValueType* data, std::size_t size, std::error_code& ec)
while
(
true
)
{
while
(
true
)
{
ssize_t
ret
;
ssize_t
ret
;
{
{
std
::
lock_guard
<
std
::
mutex
>
lk
(
pimpl_
->
sessionMutex_
);
std
::
lock_guard
<
std
::
mutex
>
lk
(
pimpl_
->
session
Read
Mutex_
);
if
(
!
pimpl_
->
session_
)
if
(
!
pimpl_
->
session_
)
return
0
;
return
0
;
ret
=
gnutls_record_recv
(
pimpl_
->
session_
,
data
,
size
);
ret
=
gnutls_record_recv
(
pimpl_
->
session_
,
data
,
size
);
...
...
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