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

uac_registrant: compare Contact URI case-insensitively #3263

Closed
wants to merge 1 commit into from

Conversation

jes
Copy link
Contributor

@jes jes commented Dec 1, 2023

Summary

We had an issue where the response Contact URI had ";transport=udp" changed to ";transport=UDP".

Details

The unequal casing of "UDP" meant that uac_registrant did not recognise the Contact header, and therefore ignored the ;expires=... value on the header, leading to OpenSIPS failing to re-register the user at the correct interval.

Solution

This commit solves the problem by comparing the Contact URI case-insensitively.

Compatibility

I doubt this breaks any scenarios.

Closing issues

We had an issue where the response Contact URI had ";transport=udp"
changed to ";transport=UDP".

This commit solves the problem by comparing the Contact URI
case-insensitively.
@vasilevalex
Copy link
Contributor

Maybe we can continue and improve this one #2558 ?

@@ -482,7 +482,7 @@ int run_reg_tm_cback(void *e_data, void *data, void *r_data)
while (contact) {
/* Check for binding */
if (contact->uri.len==rec->contact_uri.len &&
strncmp(contact->uri.s,rec->contact_uri.s,contact->uri.len)==0){
strncasecmp(contact->uri.s,rec->contact_uri.s,contact->uri.len)==0){
Copy link
Member

Choose a reason for hiding this comment

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

This is not correct because if the username was altered, the URIs are not the same:
sip:[email protected];Transport=udp (different usernames)
sip:[email protected];Transport=UDP

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, what would you think of adding a strncmp_lc_transport that takes a pkg_malloc copy of both strings, turns the ;transport=... into lowercase, then strcmps the copies with lowercased transport, and then frees the copies and returns the result of the strcmp?

Copy link
Member

Choose a reason for hiding this comment

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

Take a look at compare_uris() from parse_uri.c.
It does the proper job if URIs are passed as parsed structures, but comparing raw URIs is bad :(
I pushed some fixes on the compare_uris branch:
https://github.com/OpenSIPS/opensips/tree/compare_uris
Please give it a try and let me know the results.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the work on this, yes this looks good to me!

Copy link
Member

Choose a reason for hiding this comment

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

Did you test the new branch in production and it's working ok for you?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not in production, no, only in a test setup. I registered a user with incorrect case in the transport param and it worked & did not cause any obvious issues.

Copy link

Any updates here? No progress has been made in the last 30 days, marking as stale.

@github-actions github-actions bot added the stale label Jan 11, 2024
@jes
Copy link
Contributor Author

jes commented Jan 11, 2024

No updates here.

@stale stale bot removed the stale label Jan 11, 2024
Copy link

Any updates here? No progress has been made in the last 30 days, marking as stale.

@github-actions github-actions bot added the stale label Feb 11, 2024
@jes
Copy link
Contributor Author

jes commented Feb 11, 2024

No updates here.

@stale stale bot removed the stale label Feb 11, 2024
@ovidiusas
Copy link
Member

ovidiusas commented Feb 11, 2024 via email

@jes
Copy link
Contributor Author

jes commented Feb 12, 2024

Oh! Great success, thank you!

@jes jes closed this Feb 12, 2024
@jes
Copy link
Contributor Author

jes commented Feb 23, 2024

Hi @ovidiusas @bogdan-iancu - how come this change didn't make it into 3.4.4?

@jes
Copy link
Contributor Author

jes commented Feb 26, 2024

Reopening for visibility.

@jes jes reopened this Feb 26, 2024
Copy link

Any updates here? No progress has been made in the last 30 days, marking as stale.

@github-actions github-actions bot added the stale label Mar 29, 2024
@jes
Copy link
Contributor Author

jes commented Mar 29, 2024

It was merged but not included in the release?

@github-actions github-actions bot removed the stale label Mar 30, 2024
Copy link

Any updates here? No progress has been made in the last 30 days, marking as stale.

@github-actions github-actions bot added the stale label Apr 29, 2024
@jes
Copy link
Contributor Author

jes commented Apr 29, 2024

As per #3263 (comment) - a fix was merged but didn't make it into the release, what is happening there?

@stale stale bot removed the stale label Apr 29, 2024
Copy link

github-actions bot commented Jun 2, 2024

Any updates here? No progress has been made in the last 30 days, marking as stale.

@github-actions github-actions bot added the stale label Jun 2, 2024
@jes
Copy link
Contributor Author

jes commented Jun 2, 2024

Per https://www.opensips.org/pub/opensips/3.5.0-beta/ChangeLog it looks like this is going to make it into a release, closing.

@jes jes closed this Jun 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants