[Asterisk-code-review] res_pjsip_stir_shaken.c: Fix enabled when not configured. (asterisk[18.11])

Benjamin Keith Ford asteriskteam at digium.com
Tue Apr 26 11:11:34 CDT 2022


Benjamin Keith Ford has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/18438 )

Change subject: res_pjsip_stir_shaken.c: Fix enabled when not configured.
......................................................................

res_pjsip_stir_shaken.c: Fix enabled when not configured.

There was an issue with the conditional where STIR/SHAKEN would be
enabled even when not configured. It has been changed to ensure that if
a profile does not exist and stir_shaken is not set in pjsip.conf, then
the conditional will return from the function without performing
STIR/SHAKEN operations.

ASTERISK-30024

Change-Id: I41286a3d35b033ccbfbe4129427a62cb793a86e6
---
M res/res_pjsip_stir_shaken.c
1 file changed, 12 insertions(+), 2 deletions(-)

Approvals:
  Friendly Automation: Verified
  Benjamin Keith Ford: Looks good to me, approved; Approved for Submit



diff --git a/res/res_pjsip_stir_shaken.c b/res/res_pjsip_stir_shaken.c
index 19e846f..82c8df0 100644
--- a/res/res_pjsip_stir_shaken.c
+++ b/res/res_pjsip_stir_shaken.c
@@ -225,8 +225,13 @@
 	}
 
 	profile = ast_stir_shaken_get_profile(session->endpoint->stir_shaken_profile);
+	/* Profile should be checked first as it takes priority over anything else.
+	 * If there is a profile and it doesn't have verification enabled, do nothing.
+	 * If there is no profile and the stir_shaken option is either not set or does
+	 * not support verification, do nothing.
+	 */
 	if ((profile && !ast_stir_shaken_profile_supports_verification(profile))
-		&& ((session->endpoint->stir_shaken & AST_SIP_STIR_SHAKEN_VERIFY) == 0)) {
+		|| (!profile && (session->endpoint->stir_shaken & AST_SIP_STIR_SHAKEN_VERIFY) == 0)) {
 		return 0;
 	}
 
@@ -478,8 +483,13 @@
 	RAII_VAR(struct stir_shaken_profile *, profile, NULL, ao2_cleanup);
 
 	profile = ast_stir_shaken_get_profile(session->endpoint->stir_shaken_profile);
+	/* Profile should be checked first as it takes priority over anything else.
+	 * If there is a profile and it doesn't have attestation enabled, do nothing.
+	 * If there is no profile and the stir_shaken option is either not set or does
+	 * not support attestation, do nothing.
+	 */
 	if ((profile && !ast_stir_shaken_profile_supports_attestation(profile))
-		&& ((session->endpoint->stir_shaken & AST_SIP_STIR_SHAKEN_ATTEST) == 0)) {
+		|| (!profile && (session->endpoint->stir_shaken & AST_SIP_STIR_SHAKEN_ATTEST) == 0)) {
 		return;
 	}
 

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/18438
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 18.11
Gerrit-Change-Id: I41286a3d35b033ccbfbe4129427a62cb793a86e6
Gerrit-Change-Number: 18438
Gerrit-PatchSet: 1
Gerrit-Owner: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220426/f7b366d6/attachment-0001.html>


More information about the asterisk-code-review mailing list