Skip to content

uac_registrant: compare Contact URI case-insensitively#3263

Closed
jes wants to merge 1 commit into
OpenSIPS:masterfrom
jes:jes/registrant-strncasecmp
Closed

uac_registrant: compare Contact URI case-insensitively#3263
jes wants to merge 1 commit into
OpenSIPS:masterfrom
jes:jes/registrant-strncasecmp

Conversation

@jes

@jes jes commented Dec 1, 2023

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

Maybe we can continue and improve this one #2558 ?

/* 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
Copy Markdown
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:alice@AtLanTa.CoM;Transport=udp (different usernames)
sip:ALICE@AtLanTa.CoM;Transport=UDP

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@github-actions

Copy link
Copy Markdown

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

jes commented Jan 11, 2024

Copy link
Copy Markdown
Contributor Author

No updates here.

@stale stale Bot removed the stale label Jan 11, 2024
@github-actions

Copy link
Copy Markdown

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

jes commented Feb 11, 2024

Copy link
Copy Markdown
Contributor Author

No updates here.

@stale stale Bot removed the stale label Feb 11, 2024
@ovidiusas

ovidiusas commented Feb 11, 2024 via email

Copy link
Copy Markdown
Member

@jes

jes commented Feb 12, 2024

Copy link
Copy Markdown
Contributor Author

Oh! Great success, thank you!

@jes jes closed this Feb 12, 2024
@jes

jes commented Feb 23, 2024

Copy link
Copy Markdown
Contributor Author

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

@jes

jes commented Feb 26, 2024

Copy link
Copy Markdown
Contributor Author

Reopening for visibility.

@jes jes reopened this Feb 26, 2024
@github-actions

Copy link
Copy Markdown

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

jes commented Mar 29, 2024

Copy link
Copy Markdown
Contributor Author

It was merged but not included in the release?

@github-actions github-actions Bot removed the stale label Mar 30, 2024
@github-actions

Copy link
Copy Markdown

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

jes commented Apr 29, 2024

Copy link
Copy Markdown
Contributor Author

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
@github-actions

github-actions Bot commented Jun 2, 2024

Copy link
Copy Markdown

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

jes commented Jun 2, 2024

Copy link
Copy Markdown
Contributor Author

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