Skip to content

Instantly share code, notes, and snippets.

@alexeagle
Created May 20, 2021 01:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexeagle/71d39f470ba45c7f8a7fcc38a70bfd8c to your computer and use it in GitHub Desktop.
Save alexeagle/71d39f470ba45c7f8a7fcc38a70bfd8c to your computer and use it in GitHub Desktop.
commit 7adef170ba0ec1b379b3fd5e2e55dfd865bd2bda
Author: Alex Eagle <eagle@post.harvard.edu>
Date: Wed May 19 18:11:31 2021 -0700
experiment: reject WriteResource requests over 10MB
diff --git a/server/grpc_bytestream.go b/server/grpc_bytestream.go
index a2e4826..9820f02 100644
--- a/server/grpc_bytestream.go
+++ b/server/grpc_bytestream.go
@@ -336,6 +336,7 @@ func (s *grpcServer) parseWriteResource(r string) (string, int64, casblob.Compre
var errWriteOffset error = errors.New("bytestream writes from non-zero offsets are unsupported")
var errDecoderPoolFail error = errors.New("failed to get DecoderWrapper from pool")
+var errRequestObjectTooLarge error = errors.New("write request exceeds configured maximum object size")
func (s *grpcServer) Write(srv bytestream.ByteStream_WriteServer) error {
@@ -411,6 +412,11 @@ func (s *grpcServer) Write(srv bytestream.ByteStream_WriteServer) error {
return
}
+ if (size > 10 * 1024 * 1024) {
+ recvResult <- errRequestObjectTooLarge
+ return
+ }
+
resp.CommittedSize = req.WriteOffset
if req.WriteOffset != 0 {
err = errWriteOffset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment