]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip_stir_shaken.c: Fix enabled when not configured.
authorBen Ford <bford@digium.com>
Thu, 21 Apr 2022 15:26:01 +0000 (10:26 -0500)
committerBenjamin Keith Ford <bford@digium.com>
Tue, 26 Apr 2022 16:10:49 +0000 (11:10 -0500)
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

res/res_pjsip_stir_shaken.c

index 0637a6672ff50131a1f2474d27823a8a8a251017..bcc47d5f429a9bdc5331bb02f09ee68a6a62181f 100644 (file)
@@ -228,8 +228,13 @@ static int stir_shaken_incoming_request(struct ast_sip_session *session, pjsip_r
        }
 
        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;
        }
 
@@ -481,8 +486,13 @@ static void stir_shaken_outgoing_request(struct ast_sip_session *session, pjsip_
        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;
        }