diff options
author | obscuren <geffobscura@gmail.com> | 2015-03-10 00:28:12 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-03-10 00:28:12 +0800 |
commit | 676a0de58d3d7c508b0eeeff192d2095a46f7382 (patch) | |
tree | 43f0102374425e312e422a0baade164cc03ccf43 /rpc | |
parent | 20741a96ac6dc824bcc7d67e7c966fa65cbb2faf (diff) | |
download | go-tangerine-676a0de58d3d7c508b0eeeff192d2095a46f7382.tar go-tangerine-676a0de58d3d7c508b0eeeff192d2095a46f7382.tar.gz go-tangerine-676a0de58d3d7c508b0eeeff192d2095a46f7382.tar.bz2 go-tangerine-676a0de58d3d7c508b0eeeff192d2095a46f7382.tar.lz go-tangerine-676a0de58d3d7c508b0eeeff192d2095a46f7382.tar.xz go-tangerine-676a0de58d3d7c508b0eeeff192d2095a46f7382.tar.zst go-tangerine-676a0de58d3d7c508b0eeeff192d2095a46f7382.zip |
Max size JSON data. Closes #418
Diffstat (limited to 'rpc')
-rw-r--r-- | rpc/http/server.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/rpc/http/server.go b/rpc/http/server.go index 452b7c9af..d8f0157f1 100644 --- a/rpc/http/server.go +++ b/rpc/http/server.go @@ -29,6 +29,8 @@ import ( var rpchttplogger = logger.NewLogger("RPC-HTTP") var JSON rpc.JsonWrapper +const maxSizeReqLength = 1024 * 1024 // 1MB + func NewRpcHttpServer(pipe *xeth.XEth, address string, port int) (*RpcHttpServer, error) { sport := fmt.Sprintf("%s:%d", address, port) l, err := net.Listen("tcp", sport) @@ -92,6 +94,12 @@ func (s *RpcHttpServer) apiHandler(api *rpc.EthereumApi) http.Handler { rpchttplogger.DebugDetailln("Handling request") + if req.ContentLength > maxSizeReqLength { + jsonerr := &rpc.RpcErrorObject{-32700, "Error: Request too large"} + JSON.Send(w, &rpc.RpcErrorResponse{JsonRpc: jsonrpcver, ID: nil, Error: jsonerr}) + return + } + reqParsed, reqerr := JSON.ParseRequestBody(req) if reqerr != nil { jsonerr := &rpc.RpcErrorObject{-32700, "Error: Could not parse request"} |