Skip to content

server: null-check public IP before the DNS/Source NAT guard in creat… - #14027

Open
nagaboinaramgopal wants to merge 1 commit into
apache:mainfrom
nagaboinaramgopal:fix/lb-dns-port-npe
Open

server: null-check public IP before the DNS/Source NAT guard in creat…#14027
nagaboinaramgopal wants to merge 1 commit into
apache:mainfrom
nagaboinaramgopal:fix/lb-dns-port-npe

Conversation

@nagaboinaramgopal

Copy link
Copy Markdown

Description

Description

createPublicLoadBalancerRule guards a special case for the DNS port before it
has resolved the public IP:

if (srcPortStart == DNS_PORT && ipVO.isSourceNat()) {

When the caller does not pass an explicit IP (ipAddrId is null), ipVO is null
at this point, so creating a load balancer rule on the DNS port throws a
NullPointerException instead of the normal validation error. Fixed by
null-checking ipVO before calling isSourceNat(), so the DNS/Source NAT branch
is skipped when there is no IP and the flow reaches the intended parameter
validation.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Feature/Enhancement Scale or Bug Severity

Bug Severity

  • Minor

How Has This Been Tested?

Added a unit test that creates a public load balancer rule on the DNS port with
no explicit IP and asserts it fails with a parameter validation error instead of
a NullPointerException. Also built the standard packages and deployed on a KVM
advanced zone.

…ePublicLoadBalancerRule

createPublicLoadBalancerRule resolved ipVO only when an ipAddrId was supplied,
then at the port-53 check did (srcPortStart == DNS_PORT && ipVO.isSourceNat()).
For an elastic-LB rule created without an explicit IP (ipAddrId == null) the
system IP is allocated later, so ipVO was still null and creating a rule on
port 53 threw a NullPointerException. The ipVO == null validation only runs
further down.

Guard the check with ipVO != null so the DNS/Source NAT conflict test is
skipped when there is no IP yet; the flow then reaches the existing
can't-find-source-IP parameter error.

Adds a regression test creating a port-53 rule with a null ipAddrId
(NullPointerException before the fix).

@DaanHoogland DaanHoogland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

clgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants