Skip to content

fix: null-guard TCP phy user pointer - #295

Open
brukberhane wants to merge 1 commit into
zerotier:mainfrom
brukberhane:fix/tcp-phy-null-uptr
Open

brukberhane wants to merge 1 commit into
zerotier:mainfrom
brukberhane:fix/tcp-phy-null-uptr

Conversation

@brukberhane

@brukberhane brukberhane commented Sep 2, 2026

Copy link
Copy Markdown

Summary

  • phyOnTcpConnect already treats a null *uptr as a closed socket (_phy.close(sock, true)).
  • phyOnTcpData and phyOnTcpWritable dereference it as TcpConnection* with no check.
  • A TCP data or writable event with a null user pointer SIGSEGVs in NodeService on the libzt-node thread and kills the process.

Changes

  • Same sanity check as phyOnTcpConnect: if tc is null, close the socket and return.

phyOnTcpClose already null-checks. No other TcpConnection* callbacks in this file.

ZeroTierOne service/OneService.cpp has the same unguarded data/writable path (connect is already guarded). This PR only touches libzt NodeService.cpp.

Test plan

  • Long-lived zts_node_start with TCP relay/fallback traffic; no SIGSEGV in phyOnTcpData / phyOnTcpWritable
  • Normal connect/close still delivers tunnel packets

phyOnTcpConnect already bails on null *uptr; data/writable
did not. Null deref SIGSEGV on libzt-node kills the process
and leaves HTTP_PROXY pointing at a dead loopback.
@CLAassistant

CLAassistant commented Sep 2, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@someara

someara commented Sep 2, 2026 via email

Copy link
Copy Markdown
Contributor

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.

3 participants