mirror of
https://github.com/fatedier/frp.git
synced 2026-05-15 08:05:49 -06:00
[PR #5214] [MERGED] fix: concurrent map crash, error shadowing, and unchecked ListenUDP error #5179
Labels
No labels
In Progress
WIP
WaitingForInfo
bug
doc
duplicate
easy
enhancement
future
help wanted
invalid
lifecycle/stale
need-issue-template
need-usage-help
no plan
proposal
pull-request
question
todo
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/frp#5179
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/fatedier/frp/pull/5214
Author: @fatedier
Created: 3/7/2026
Status: ✅ Merged
Merged: 3/7/2026
Merged by: @fatedier
Base:
dev← Head:new📝 Commits (1)
cbe65d8fix: three high-severity bugs across nathole, proxy, and udp modules📊 Changes
3 files changed (+8 additions, -1 deletions)
View changed files
📝
pkg/nathole/controller.go(+2 -0)📝
pkg/util/net/udp.go(+4 -0)📝
server/proxy/proxy.go(+2 -1)📄 Description
Summary
Fixes three high-severity bugs found via static analysis and cross-verified by Codex:
pkg/nathole: concurrent map read/write crash —
HandleVisitorPreCheck path readsc.clientCfgswithout lock whileListenClient/CloseClientmodify it underc.mu. Since the handler runs viamsg.AsyncHandler(goroutine), this is a data race that can crash the server withconcurrent map read and map write. Fix: addc.mu.RLock()around the map read.server/proxy: closed connection returned with nil error —
GetWorkConnFromPooluseserr := msg.WriteMsg(...)(short variable declaration) which shadows the outer named returnerr. WhenpoolCountis 0 andWriteMsgfails, the outererrstays nil, causing the function to return a closedworkConnwith no error. Fix: useerr =instead oferr :=, and setworkConn = nilafter closing.pkg/util/net: nil pointer panic on ListenUDP failure —
net.ListenUDPerror was not checked before spawning goroutines that callreadConn.ReadFromUDP. If listen fails,readConnis nil → panic. Alsol.readConnwas never assigned, makingClose()a no-op. Fix: check error and return early, assignreadConnto struct field.Test plan
make buildpassesmake testpasses🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.