Skip to content

Commit

Permalink
operator/pkg/certs: fix null ptr deref in altnames
Browse files Browse the repository at this point in the history
In this commit, we fix th null pointer dereference issue
that happens in altnames mutators for both Karmada APIServer
and EtcdServer when accessing the `Components` field on
`AltNamesMutatorConfig` struct.

Signed-off-by: Mohamed Awnallah <mohamedmohey2352@gmail.com>
  • Loading branch information
mohamedawnallah committed Sep 16, 2024
1 parent 671372a commit 89794f1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions operator/pkg/certs/certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ func etcdServerAltNamesMutator(cfg *AltNamesMutatorConfig) (*certutil.AltNames,
IPs: []net.IP{net.IPv4(127, 0, 0, 1)},
}

if cfg.Components.Etcd.Local != nil {
if cfg.Components != nil && cfg.Components.Etcd != nil && cfg.Components.Etcd.Local != nil {
appendSANsToAltNames(altNames, cfg.Components.Etcd.Local.ServerCertSANs)
}

Expand Down Expand Up @@ -488,7 +488,7 @@ func apiServerAltNamesMutator(cfg *AltNamesMutatorConfig) (*certutil.AltNames, e
fmt.Sprintf("*.%s.svc", cfg.Namespace)})
}

if len(cfg.Components.KarmadaAPIServer.CertSANs) > 0 {
if cfg.Components != nil && cfg.Components.KarmadaAPIServer != nil && len(cfg.Components.KarmadaAPIServer.CertSANs) > 0 {
appendSANsToAltNames(altNames, cfg.Components.KarmadaAPIServer.CertSANs)
}
if len(cfg.ControlplaneAddress) > 0 {
Expand Down

0 comments on commit 89794f1

Please sign in to comment.