Skip to content

tailcat: drop null regions and nodes from fetched DERP maps - #204

Open
shoemoney wants to merge 1 commit into
tailscale:mainfrom
shoemoney:fix/fetchderpmap-null-regions
Open

shoemoney wants to merge 1 commit into
tailscale:mainfrom
shoemoney:fix/fetchderpmap-null-regions

Conversation

@shoemoney

@shoemoney shoemoney commented Nov 28, 2026 •

Copy link
Copy Markdown

#183 made Expand skip JSON nulls in a DERP map, but FetchDERPMap still hands them back as nil pointers and genkey dereferences them.

To reproduce on main, serve this map locally:

{"Regions":{"1":null,"2":{"RegionID":2,"RegionCode":"two","RegionName":"Two","Nodes":[null,{"Name":"2a","RegionID":2,"HostName":"a.example.com"}]}}}
$ tailcat --derpmap-url=http://127.0.0.1:18765/map.json genkey --region=list
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xd6b723]

goroutine 1 [running]:
main.genKey.func2(...)
	cmd/tailcat/tailcat.go:2272 +0x3

With this change it prints 2 two Two.

I dropped the nulls in decodeDERPMap so a fresh fetch, a cache hit and the stale fallback all get the same treatment. Expand keeps its own check, since callers can still pass it a map directly.

TestFetchDERPMapSkipsNulls fails without the tailcat.go change ("got 2 regions, want 1") and go test . passes with it.

Expand already skips JSON nulls in a DERP map, but FetchDERPMap and
the cmd/tailcat genkey path that calls it returned them as nil
pointers. "tailcat --derpmap-url=URL genkey --region=list" against a
map with a null region panicked in the region sort.

Drop the nulls in decodeDERPMap, so every fetch, cache hit and stale
fallback is clean.

Signed-off-by: Jeremy Schoemaker <jeremy@shoemoney.com>

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant