Skip to content

Commit

Permalink
Fix crash in pillar if NTP FQDN is an empty string
Browse files Browse the repository at this point in the history
Under some conditions e.g. when set from Monitor TUI NTP FQDN can be an
empty string which causes a crash

pillar;panic: runtime error: index out of range -1]

pillar;goroutine 170248 [running]:
pillar;github.com/lf-edge/eve/pkg/pillar/devicenetwork.ResolveWithSrcIP({0x0, 0x0}, {0xc002631950, 0x10, 0x10}, {0xc002631960, 0x10, 0x10})
pillar;  /pillar/devicenetwork/dns.go:79 +0x4d4
pillar;github.com/lf-edge/eve/pkg/pillar/devicenetwork.ResolveCacheWrap.func1({0x0, 0x0}, {0xc002631950, 0x10, 0x10}, {0xc002631960, 0x10, 0x10})
pillar;  /pillar/devicenetwork/dns.go:122 +0x1ca
pillar;github.com/lf-edge/eve/pkg/pillar/devicenetwork.ResolveWithPortsLambda.func1({0xc002631950, 0x10, 0x10}, {0xc002631960, 0x10, 0x10})
pillar;  /pillar/devicenetwork/dns.go:198 +0x17b
pillar;created by github.com/lf-edge/eve/pkg/pillar/devicenetwork.ResolveWithPortsLambda
pillar;  /pillar/devicenetwork/dns.go:182 +0x98a

Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
  • Loading branch information
rucoder committed Jan 22, 2025
1 parent f309671 commit d1cdbd7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/pillar/cmd/zedrouter/networkinstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ func (z *zedrouter) attachNTPServersToPortConfigs(portConfigs []nireconciler.Por
ntpServers = append(ntpServers, ip)
continue
}

if len(strings.TrimSpace(ntpServer)) == 0 {
continue
}

z.pubSub.StillRunning(agentName, warningTime, errorTime)
dnsResponses, err := devicenetwork.ResolveWithPortsLambda(
ntpServer,
Expand Down

0 comments on commit d1cdbd7

Please sign in to comment.