Skip to content

libtailscale: return errors from enable_funnel instead of panicking - #75

Open
shoemoney wants to merge 1 commit into
tailscale:mainfrom
shoemoney:fix/funnel-no-cert-domains
Open

shoemoney wants to merge 1 commit into
tailscale:mainfrom
shoemoney:fix/funnel-no-cert-domains

Conversation

@shoemoney

@shoemoney shoemoney commented Nov 28, 2026 •

Copy link
Copy Markdown

tailscale_enable_funnel_to_localhost_plaintext_http1 indexes st.CertDomains[0] without a length check. On a tailnet that hasn't enabled HTTPS certificates the slice is empty, so the call panics inside cgo and takes the embedding process down with it. It now returns -1 and sets tailscale_errmsg.

While I was in there: the function threw away the error from SetServeConfig and then checked sc.AllowFunnel[hp], a map it had just filled in itself. That branch could never run, so a failed set returned 0. It now returns the SetServeConfig error.

The test brings a node up against testcontrol, which hands out no cert domains, and calls the function. On main:

--- FAIL: TestFunnelNoCertDomains
panic: runtime error: index out of range [0] with length 0 [recovered, repanicked]

I couldn't find a way to make SetServeConfig fail under testcontrol, so that path is untested.

Fixes tailscale/tailscale#22713

tailscale_enable_funnel_to_localhost_plaintext_http1 indexed
st.CertDomains[0] without checking the slice. On a tailnet without
HTTPS enabled, CertDomains is empty and the call panicked inside cgo,
aborting the host process. Return an error with a message instead.

It also discarded the error from SetServeConfig and then checked
sc.AllowFunnel, a map the function had just filled itself, so the
failure branch could never run. Return the SetServeConfig error.

Fixes tailscale/tailscale#22713

Change-Id: Icbf789ac5c03cec8b35f115a5cc6e97dd28c9e91
Signed-off-by: Jeremy Schoemaker <jeremy@shoemoney.com>
@shoemoney
shoemoney force-pushed the fix/funnel-no-cert-domains branch from 49b362f to e0fe650 Compare November 28, 2026 18:41
@shoemoney shoemoney changed the title libtailscale: report errors from enable_funnel instead of panicking or ignoring them libtailscale: return errors from enable_funnel instead of panicking Nov 28, 2026
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.

libtailscale: tailscale_enable_funnel_to_localhost_plaintext_http1 panics when the tailnet has no cert domains

1 participant