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

HostAndPort fails to parse a nip host #4948

Merged
merged 1 commit into from
Nov 15, 2023

Conversation

tsegismont
Copy link
Contributor

See #4947

If parseIPv4Address finds an IP address, and the string still has characters which do not begin with :, this is not an IP address.

In other words, 10.0.0.1.nip.io should not be parsed as IP address.

See eclipse-vertx#4947

If parseIPv4Address finds an IP address, and the string still has characters which do not begin with `:`, this is not an IP address.

In other words, 10.0.0.1.nip.io should not be parsed as IP address.

Signed-off-by: Thomas Segismont <[email protected]>
@cescoffier cescoffier merged commit 3dba400 into eclipse-vertx:master Nov 15, 2023
6 checks passed
@vietj
Copy link
Member

vietj commented Nov 15, 2023

I am not certain this is the correct fix to do

@vietj
Copy link
Member

vietj commented Nov 15, 2023

The fix makes reg names parsed as IPV4 addresses when they are prefixed by an IPV4 string which makes the impl of parseIPv4Address wrong as it accepts more than it should and testParseIPV4Address has been added incorrect assertions.

Instead the code using parseIPV4Address should check when this method returns a positive value, than the returned position is actually the end of the string or followed by :.

The correct thing to do should be

  static int parseHost(String val, int from, int to) {
    int pos;
    if ((pos = parseIPLiteral(val, from, to)) != -1) {
      return pos;
    } else if ((pos = parseIPv4Address(val, from, to)) != -1 && (pos == to || val.charAt(pos + 1 ) == ':') ) {
      return pos;
    } else if ((pos = parseRegName(val, from, to)) != -1) {
      return pos;
    }
    return -1;
  }

@tsegismont tsegismont removed the request for review from vietj November 15, 2023 13:26
@tsegismont tsegismont deleted the issue-4947 branch November 15, 2023 13:54
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