From ff9102bc2aae364eb837708749fe5c3e7f8dbc76 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Fri, 4 Dec 2026 01:31:43 -0800 Subject: [PATCH] sftp: cap what the test filer reads from an upload An upload that wrongly carries a large hole now fails the test instead of filling memory. Co-Authored-By: Claude Opus 5.5 --- weed/sftpd/sftp_read_write_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weed/sftpd/sftp_read_write_test.go b/weed/sftpd/sftp_read_write_test.go index abd3a475b3..099e78a50c 100644 --- a/weed/sftpd/sftp_read_write_test.go +++ b/weed/sftpd/sftp_read_write_test.go @@ -60,7 +60,7 @@ func newRWTest(t *testing.T, perms ...string) *rwTest { fs.user.Permissions = map[string][]string{"/buckets": perms} rw := &rwTest{fs: fs, fake: fake} ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - body, _ := io.ReadAll(r.Body) + body, _ := io.ReadAll(io.LimitReader(r.Body, 1<<20)) rw.mu.Lock() rw.bodies = append(rw.bodies, string(body)) rw.mu.Unlock()