Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/internal/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ import (
"google.golang.org/grpc/status"
)

// maxCheckpointBodyBytes bounds the size of an uploaded checkpoint. Real
// checkpoints are a few hundred bytes; 100 KiB is a generous upper limit.
const maxCheckpointBodyBytes = 100 << 10

// Distributor persists witnessed checkpoints and allows querying of them.
type Distributor interface {
// GetLogs returns a list of all log IDs the distributor is aware of, sorted
Expand Down Expand Up @@ -65,6 +69,7 @@ func (s *Server) update(w http.ResponseWriter, r *http.Request) {
v := mux.Vars(r)
logID := v["logid"]
witID := v["witid"]
r.Body = http.MaxBytesReader(w, r.Body, maxCheckpointBodyBytes)
body, err := io.ReadAll(r.Body)
if err != nil {
http.Error(w, fmt.Sprintf("cannot read request body: %v", err.Error()), http.StatusBadRequest)
Expand Down
Loading