From 17ac0c25d131efb9bc59e9b2f06eb611843b07df Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Mon, 4 Sep 2023 13:28:21 +0300 Subject: [PATCH] Fix potential NPE in HTTP proxying Fixes: #35706 (cherry picked from commit bcd2edb380ee52f14259be5fdc61a9adde5b6bb8) --- .../java/io/quarkus/vertx/http/runtime/ForwardedParser.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardedParser.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardedParser.java index 6fe05d63185aa..0bdee036fbf3b 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardedParser.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardedParser.java @@ -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); @@ -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); } } }