Skip to content

Commit 6457632

Browse files
committed
fix: limit HTTP request body size to prevent OOM
1 parent 6e84a53 commit 6457632

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

cmd/p2p/sensor/rpc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ func handleRPC(conns *p2p.Conns, networkID uint64) {
104104
return
105105
}
106106

107+
r.Body = http.MaxBytesReader(w, r.Body, 5*1024*1024) // 5MB limit
107108
body, err := io.ReadAll(r.Body)
108109
if err != nil {
109110
writeError(w, -32700, "Parse error", nil)

0 commit comments

Comments
 (0)