Skip to content

Conversation

maxsharabayko
Copy link
Collaborator

@maxsharabayko maxsharabayko commented Oct 9, 2024

As reported in #3035, srt/haicrypt/hcrypt_xpt_srt.c has two definitions of the static variable _hcMsg_SRT_MsgInfo:

// Line: 68
static hcrypt_MsgInfo _hcMsg_SRT_MsgInfo;
// Line: 156
static hcrypt_MsgInfo _hcMsg_SRT_MsgInfo;

One more problem is the .parseMsg field off the structure that is initialized with a pointer to hcryptMsg_SRT_ParseMsg function. The hcryptMsg_SRT_ParseMsg function in its turn uses the static _hcMsg_SRT_MsgInfo internally.

To resolve this interdependency the hcryptMsg_SRT_ParseMsg function is made visible and now requires a pointer to a hcrypt_MsgInfo structure instead of using the static variable implicitly.
The _hcMsg_SRT_MsgInfo can now be const and initialized once the following way:

static const hcrypt_MsgInfo _hcMsg_SRT_MsgInfo = {
	.hdr_len     = HCRYPT_MSG_SRT_HDR_SZ,
	.pfx_len     = HCRYPT_MSG_SRT_PFX_SZ,
	.getKeyFlags = hcryptMsg_SRT_GetKeyFlags,
	.getPki      = hcryptMsg_SRT_GetPki,
	.setPki      = hcryptMsg_SRT_SetPki,
	.resetCache  = hcryptMsg_SRT_ResetCache,
	.indexMsg    = hcryptMsg_SRT_IndexMsg,
};

Fixes #3035.

@maxsharabayko maxsharabayko added Type: Bug Indicates an unexpected problem or unintended behavior [core] Area: Changes in SRT library core labels Oct 9, 2024
@maxsharabayko maxsharabayko added this to the v1.5.4 milestone Oct 9, 2024
@maxsharabayko maxsharabayko marked this pull request as draft October 9, 2024 15:36
@maxsharabayko maxsharabayko marked this pull request as ready for review October 10, 2024 08:50
@maxsharabayko maxsharabayko merged commit e23497d into Haivision:master Oct 10, 2024
12 checks passed
@maxsharabayko maxsharabayko deleted the hotfix/crypto-static-var branch October 10, 2024 09:25
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] Static Global State Variables Used for Multiple Connections
2 participants