kmesh-net / kmesh

High Performance ServiceMesh Data Plane Based on Programmable Kernel

Home Page:https://kmesh.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing null pointer check in ads_loader.go

LiZhenCheng9527 opened this issue · comments

What happened:
Missing null pointer check in ads_loader.go
e.g.:

func newApiSocketAddress(address *config_core_v3.Address) *core_v2.SocketAddress {
var addr *config_core_v3.SocketAddress
switch address.GetAddress().(type) {
case *config_core_v3.Address_SocketAddress:
addr = address.GetSocketAddress()
default:
return nil
}
if addr == nil || !nets.GetConfig().IsEnabledProtocol(addr.GetProtocol().String()) {
return nil
}
return &core_v2.SocketAddress{
// Protocol: core_v2.SocketAddress_Protocol(addr.GetProtocol()),
Port: nets.ConvertPortToBigEndian(addr.GetPortValue()),
Ipv4: nets.ConvertIpToUint32(addr.GetAddress()),
}
}

What you expected to happen:
add nil pointer check in ads_loader.go

Environment:

  • Kmesh version:0.2.0
  • Others: