Skip to content

Conversation

@davidtrihy-genesys
Copy link
Contributor

Summary
Extends sipmsg_validate with c flag set for validating Contact headers to multiple different requests

Details
In response to my testing of the fix outlined in this PR #3803 I found limitations of the sipmsg_validate function which only applied Contact validation to INVITE.

This extends validation to REGISTER|UPDATE|SUBSCRIBE|REFER - not taking into account what type of request it is eg. initial or in dialog, so with a REFER a dialog can be created from a REFER request according to https://www.rfc-editor.org/rfc/rfc3515#section-2 but an in dialog REFER does not honour the Contact header sent but this validation logic does not check that and it will fail, it is designed to be up to the script writer to do the in dialog check themselves.

Solution
New static function created to specifically check the Contact header which will take into account multiple different aspects of the SIP message.

Failure conditions

  1. No Contact header
  2. Contact header contains * as the body and one of these other conditions
    i. Is a SIP reply
    ii. is not a REGISTER request
    iii. is a REGISTER request but the Expires header is missing or it is set to a value greater than 0

New return code of -30 for when a * is the value but is invalid for the three types of conditions listed in 2.

Compatibility
Depending on how you have written your script and if the behaviour of your OpenSIPs deployment is relying implicitly on the Contact header not being checked for the new requests it could break scripts.

@davidtrihy-genesys davidtrihy-genesys force-pushed the sipmsg_validate_all_contacts branch from 9c15692 to de9a9ba Compare January 19, 2026 15:57
@bogdan-iancu bogdan-iancu self-assigned this Jan 21, 2026
@davidtrihy-genesys davidtrihy-genesys force-pushed the sipmsg_validate_all_contacts branch from de9a9ba to 8e76c90 Compare January 22, 2026 11:28
Copy link
Member

@bogdan-iancu bogdan-iancu left a comment

Choose a reason for hiding this comment

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

The patch looks fine thank you.
If I may suggest a small simplifying of the code, to get rid of this repeating sequence of:

ret = ... ;
goto failed;

where there is just a return ret.
I would suggest simply doing an inline of return ...... ; instead of setting ret + goto. Also drop the failed label and do return SV_NO_ERROR; at the end.
Up to you if you want to do this change :)

@davidtrihy-genesys
Copy link
Contributor Author

@bogdan-iancu I did the inline return, makes more sense so ready to merge whenever CI is good thanks

@bogdan-iancu bogdan-iancu merged commit 18fdeaf into OpenSIPS:3.4 Jan 23, 2026
31 of 43 checks passed
bogdan-iancu added a commit that referenced this pull request Jan 23, 2026
Sipmsg validate all contacts

(cherry picked from commit 18fdeaf)
bogdan-iancu added a commit that referenced this pull request Jan 23, 2026
Sipmsg validate all contacts

(cherry picked from commit 18fdeaf)
@bogdan-iancu
Copy link
Member

Thank you @davidtrihy-genesys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants