Skip to content

Commit

Permalink
Fix potential NPE in HTTP proxying
Browse files Browse the repository at this point in the history
Fixes: #35706
(cherry picked from commit bcd2edb)
  • Loading branch information
geoand authored and gsmet committed Sep 13, 2023
1 parent 2715552 commit 17ac0c2
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private void calculate() {

matcher = FORWARDED_FOR_PATTERN.matcher(forwarded);
if (matcher.find()) {
remoteAddress = parseFor(matcher.group(1).trim(), remoteAddress.port());
remoteAddress = parseFor(matcher.group(1).trim(), remoteAddress != null ? remoteAddress.port() : port);
}
} else if (forwardingProxyOptions.allowXForwarded) {
String protocolHeader = delegate.getHeader(X_FORWARDED_PROTO);
Expand Down Expand Up @@ -177,7 +177,7 @@ private void calculate() {

String forHeader = delegate.getHeader(X_FORWARDED_FOR);
if (forHeader != null) {
remoteAddress = parseFor(getFirstElement(forHeader), remoteAddress.port());
remoteAddress = parseFor(getFirstElement(forHeader), remoteAddress != null ? remoteAddress.port() : port);
}
}
}
Expand Down

0 comments on commit 17ac0c2

Please sign in to comment.