mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-08-22 07:06:51 +00:00
fix(uds): guard against nil VolumeServer in handleLocate
Prevent nil pointer dereference when VolumeServer is nil by adding an early return with UdsStatusError before accessing vs.store. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
e064c86d12
commit
f20c05ea0a
@@ -189,6 +189,11 @@ func (u *UdsServer) handleLocate(req *LocateRequest) *LocateResponse {
|
||||
return resp
|
||||
}
|
||||
|
||||
if u.vs == nil {
|
||||
resp.Status = UdsStatusError
|
||||
return resp
|
||||
}
|
||||
|
||||
volumeId := fileId.VolumeId
|
||||
needleId := fileId.Key
|
||||
|
||||
|
||||
@@ -162,11 +162,10 @@ func TestUdsServerProtocol(t *testing.T) {
|
||||
t.Fatalf("Failed to read response: %v", err)
|
||||
}
|
||||
|
||||
// Since vs is nil, we expect an error status (handleLocate will panic or return error)
|
||||
// In this case, we just check we got a valid response back
|
||||
// Since vs is nil, we expect UdsStatusError
|
||||
status := respBuf[0]
|
||||
if status != UdsStatusOk && status != UdsStatusNotFound && status != UdsStatusError {
|
||||
t.Errorf("Unexpected status: %d", status)
|
||||
if status != UdsStatusError {
|
||||
t.Errorf("Expected UdsStatusError (%d) for nil VolumeServer, got %d", UdsStatusError, status)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user