rjgoyln commented on code in PR #11124:
URL: https://github.com/apache/ozone/pull/11124#discussion_r4032765384
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/VirtualHostStyleFilter.java:
##########
@@ -166,6 +184,37 @@ String checkHostWithoutPort(String host) {
}
}
+ /**
+ * Compares a host with a configured domain by address rather than by
+ * spelling, so that a client writing the gateway's address in a form other
+ * than the configured one still reaches it: ::1 and 0:0:0:0:0:0:0:1 are the
+ * same address, and hexadecimal digits may be in either case. Follows
+ * {@code SCMFailoverProxyProviderBase#sameIpLiteral} in comparing an IPv6
+ * scope as text: {@link java.net.InetAddress#equals} drops it, so
fe80::1%eth0
+ * and fe80::1%eth1 would otherwise be the same interface, and resolving a
+ * scope the gateway host does not have would throw.
+ */
+ private static boolean isSameAddress(String host, String domain) {
+ if (host.equals(domain)) {
+ return true;
+ }
+ String hostIp = stripScope(host);
+ String domainIp = stripScope(domain);
+ return scopeOf(host).equals(scopeOf(domain))
+ && InetAddresses.isInetAddress(hostIp) &&
InetAddresses.isInetAddress(domainIp)
+ &&
InetAddresses.forString(hostIp).equals(InetAddresses.forString(domainIp));
Review Comment:
OK! I have fixed in 81f2dac: ignore the configured domain’s zone identifier
and reject Host values containing one, including the %25 URI form. This also
avoids resolving the zone to a local interface.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]