@@ -43,8 +43,15 @@ const (
4343 // for not causing a read timeout.
4444 connReadLimitByte = 64 * 1024
4545
46- // snapshotLimitByte limits the snapshot size to 1TB
47- snapshotLimitByte = 1 * 1024 * 1024 * 1024 * 1024
46+ // snapshotLimitByte limits the size of the raft snapshot *message*
47+ // (metadata plus the small membership blob embedded in
48+ // raftpb.Snapshot.Data). It does NOT bound the actual database
49+ // snapshot, which is streamed separately as the rest of the request
50+ // body (see snapshotHandler.ServeHTTP and SaveDBFrom) and can be
51+ // arbitrarily large. 64MB leaves generous headroom over realistic
52+ // envelope sizes while avoiding a huge allocation from a corrupt or
53+ // malicious length prefix.
54+ snapshotLimitByte = 64 * 1024 * 1024
4855)
4956
5057var (
@@ -218,7 +225,9 @@ func (h *snapshotHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
218225 addRemoteFromRequest (h .tr , r )
219226
220227 dec := & messageDecoder {r : r .Body }
221- // let snapshots be very large since they can exceed 512MB for large installations
228+ // This only decodes the raft message envelope; the actual database
229+ // snapshot bytes that follow in the body are read separately below
230+ // via h.snapshotter.SaveDBFrom and are not subject to this limit.
222231 m , err := dec .decodeLimit (snapshotLimitByte )
223232 from := types .ID (m .From ).String ()
224233 if err != nil {
0 commit comments