Skip to content

Commit 94abc92

Browse files
committed
client: Limit reads.
An honest vspd should never return responses greater than 4MB.
1 parent e62db42 commit 94abc92

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

client/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2022-2025 The Decred developers
1+
// Copyright (c) 2022-2026 The Decred developers
22
// Use of this source code is governed by an ISC
33
// license that can be found in the LICENSE file.
44

@@ -210,7 +210,7 @@ func (c *Client) do(ctx context.Context, method, path string, addr stdaddr.Addre
210210
}
211211
}
212212

213-
respBody, err := io.ReadAll(reply.Body)
213+
respBody, err := io.ReadAll(io.LimitReader(reply.Body, 1<<22)) // 4 MiB limit
214214
if err != nil {
215215
return fmt.Errorf("read response body: %w", err)
216216
}

0 commit comments

Comments
 (0)