mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
ipn/ipnlocal: fix nil pointer dereference and add related test
Fixes #12644 Change-Id: I3589b01a9c671937192caaedbb1312fd906ca712 Signed-off-by: Adrian Dewhurst <adrian@tailscale.com>
This commit is contained in:
parent
0bb82561ba
commit
8f7588900a
@ -6578,7 +6578,7 @@ func fillAllowedSuggestions() set.Set[tailcfg.StableNodeID] {
|
||||
}
|
||||
|
||||
func suggestExitNode(report *netcheck.Report, netMap *netmap.NetworkMap, prevSuggestion tailcfg.StableNodeID, selectRegion selectRegionFunc, selectNode selectNodeFunc, allowList set.Set[tailcfg.StableNodeID]) (res apitype.ExitNodeSuggestionResponse, err error) {
|
||||
if report.PreferredDERP == 0 || netMap == nil || netMap.DERPMap == nil {
|
||||
if report == nil || report.PreferredDERP == 0 || netMap == nil || netMap.DERPMap == nil {
|
||||
return res, ErrNoPreferredDERP
|
||||
}
|
||||
candidates := make([]tailcfg.NodeView, 0, len(netMap.Peers))
|
||||
|
@ -3118,6 +3118,12 @@ func TestSuggestExitNode(t *testing.T) {
|
||||
DERPMap: defaultDERPMap,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "nil report",
|
||||
lastReport: nil,
|
||||
netMap: largeNetmap,
|
||||
wantError: ErrNoPreferredDERP,
|
||||
},
|
||||
{
|
||||
name: "no preferred derp region",
|
||||
lastReport: preferredNoneReport,
|
||||
@ -3127,6 +3133,24 @@ func TestSuggestExitNode(t *testing.T) {
|
||||
},
|
||||
wantError: ErrNoPreferredDERP,
|
||||
},
|
||||
{
|
||||
name: "nil netmap",
|
||||
lastReport: noLatency1Report,
|
||||
netMap: nil,
|
||||
wantError: ErrNoPreferredDERP,
|
||||
},
|
||||
{
|
||||
name: "nil derpmap",
|
||||
lastReport: noLatency1Report,
|
||||
netMap: &netmap.NetworkMap{
|
||||
SelfNode: selfNode.View(),
|
||||
DERPMap: nil,
|
||||
Peers: []tailcfg.NodeView{
|
||||
dallasPeer5,
|
||||
},
|
||||
},
|
||||
wantError: ErrNoPreferredDERP,
|
||||
},
|
||||
{
|
||||
name: "missing suggestion capability",
|
||||
lastReport: noLatency1Report,
|
||||
|
Loading…
Reference in New Issue
Block a user