Description
In protocol/hysteria2/realm_server.go:383, the error from json.Marshal is silently ignored:
data, _ := json.Marshal(ev.data)
fmt.Fprintf(w, "event: %s\ndata: %s\n\n", ev.kind, data)
Impact
If ev.data contains values that cannot be serialized by encoding/json (e.g., channels, functions, complex numbers, or cyclic data structures), the marshal will silently return an empty byte slice or incomplete JSON. The SSE stream will then send malformed data, and the client will receive corrupted or empty events with no indication of the error.
Location
protocol/hysteria2/realm_server.go:383
Suggested Fix
At minimum, log the error and skip the event:
data, err := json.Marshal(ev.data)
if err != nil {
return
}
fmt.Fprintf(w, "event: %s\ndata: %s\n\n", ev.kind, data)
Description
In
protocol/hysteria2/realm_server.go:383, the error fromjson.Marshalis silently ignored:Impact
If
ev.datacontains values that cannot be serialized byencoding/json(e.g., channels, functions, complex numbers, or cyclic data structures), the marshal will silently return an empty byte slice or incomplete JSON. The SSE stream will then send malformed data, and the client will receive corrupted or empty events with no indication of the error.Location
protocol/hysteria2/realm_server.go:383Suggested Fix
At minimum, log the error and skip the event: