Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed crash in craftKmResponse due to CryptoControl being NULL #2277

Merged
merged 3 commits into from
Apr 21, 2022

Conversation

maxsharabayko
Copy link
Collaborator

  1. Check if CryptoControl exists in craftKmResponse(..). Fixes [BUG] Crash in srt::CUDT::craftKmResponse from a null pointer in m_pCryptoControl #2231.
  2. Cleaned up the CUDT::processConnectRequest(..) function.

@maxsharabayko maxsharabayko added Type: Bug Indicates an unexpected problem or unintended behavior [core] Area: Changes in SRT library core labels Apr 4, 2022
@maxsharabayko maxsharabayko added this to the v1.4.5 milestone Apr 4, 2022
@maxsharabayko maxsharabayko marked this pull request as ready for review April 11, 2022 08:46
size_t exp_len =
CHandShake::m_iContentSize; // When CHandShake::m_iContentSize is used in log, the file fails to link!
// When CHandShake::m_iContentSize is used in log, the file fails to link!
size_t exp_len = CHandShake::m_iContentSize;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be fixed easier - in 10772 use +CHandShake::m_iContentSize instead of exp_len.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I can see, you wrote that exactly this (using the CHandShake::m_iContentSize in log) fails to link.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You missed the + before the name. This is exactly what fixes the problem.

@@ -3908,6 +3908,14 @@ EConnectStatus srt::CUDT::craftKmResponse(uint32_t* aw_kmdata, size_t& w_kmdatas
int hs_flags = SrtHSRequest::SRT_HSTYPE_HSFLAGS::unwrap(m_ConnRes.m_iType);
if (IsSet(hs_flags, CHandShake::HS_EXT_KMREQ))
{
if (!m_pCryptoControl)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lacks an explanation as to why this fixes the problem. This function should at best have:

  • The declarations of all mutexes that are locked before calling this function and made sure that the list is stable against all places from which this function is called
  • In all places that can modify m_pCryptoControl make sure that locking on that place can exclude the possibility of modifying this field anywhere up to the end of this function (mention these places here)

Update listener write-ready only after the new connection.
Was changed in Haivision#1650, but must not be done at all (see Haivision#1831).
@maxsharabayko maxsharabayko merged commit 48d1364 into Haivision:master Apr 21, 2022
@maxsharabayko maxsharabayko deleted the hotfix/craftkm-crash branch April 21, 2022 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[core] Area: Changes in SRT library core Type: Bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Crash in srt::CUDT::craftKmResponse from a null pointer in m_pCryptoControl
2 participants