Skip to content

Conversation

@stefankiesz
Copy link
Contributor

@stefankiesz stefankiesz commented Nov 24, 2025

Issue #, if available:

  • N/A

What was changed?

  • isIpAddr now considers the length of the inputted string compared to the IP-format-matched string.

Why was it changed?

  • To prevent false positives from the isIpAddr function.

How was it changed?

  • If the length of the inputted string does not match the length of the formatted string, then the function returns false, even if it was able to fill the template to make an IP address.

What testing was done for the changes?

  • Ran p2p test locally using a hardcoded TURN hostname in the format "turn:44.251.170.58?transport=udp" which resulted in isIpAddr returning false.
  • Ran p2p test locally using a hardcoded TURN hostname in the format "turn:44.251.170.58" which resulted in isIpAddr returning true (the SDK removes the 'turn:' prefix before calling isIpaddr), and resulted in a successful relayed WebRTC streaming session.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@stefankiesz stefankiesz marked this pull request as ready for review November 24, 2025 18:12
@stefankiesz stefankiesz requested review from YPandas, Copilot, sirknightj and unicornss and removed request for Copilot November 24, 2025 18:12
@stefankiesz stefankiesz requested a review from Ahhorse1 November 24, 2025 18:13
Copilot finished reviewing on behalf of stefankiesz November 24, 2025 18:14

// Check if IPv6 address.
offset = 0;
if (sscanf(hostname, "%x:%x:%x:%x:%x:%x:%x:%x%n", &ip_1, &ip_2, &ip_3, &ip_4, &ip_5, &ip_6, &ip_7, &ip_8, &offset) == 8 &&

Choose a reason for hiding this comment

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

Should we do checks here as similar to the <= 255 done for IPv4?

@stefankiesz stefankiesz marked this pull request as draft November 25, 2025 16:02
return status;

// Check if IPv4 address.
if (sscanf(hostname, "%u.%u.%u.%u%n", &ip_1, &ip_2, &ip_3, &ip_4, &offset) == 4 && ip_1 <= 255 && ip_2 <= 255 && ip_3 <= 255 && ip_4 <= 255 &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the IPV4/IPV6 template still used?
Also suggest to use the macro version SSCANF and STRLEN

@sirknightj
Copy link
Contributor

Would like to see a new testcase added for the ?transport=udp mentioned

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.

3 participants