From 33e30f31e13dfa395c509a55f71e86f877b7687f Mon Sep 17 00:00:00 2001 From: Romain Menke Date: Tue, 21 Nov 2023 11:05:40 +0100 Subject: [PATCH 1/2] fix stackoverflow in ReadFrom - failing test --- http/interceptor_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/http/interceptor_test.go b/http/interceptor_test.go index e4da8e700..d232996bf 100644 --- a/http/interceptor_test.go +++ b/http/interceptor_test.go @@ -214,6 +214,11 @@ func TestReadFrom(t *testing.T) { t.Errorf("unexpected error: %v", err) } + _, err = rw.(io.ReaderFrom).ReadFrom(struct{ io.Reader }{bytes.NewBuffer([]byte("hello world"))}) + if err != nil { + t.Errorf("unexpected error: %v", err) + } + err = responseProcessor(tx, req) if err != nil { t.Errorf("unexpected error: %v", err) From eeda3b790bdab1ae409c5942373b2225dab25b61 Mon Sep 17 00:00:00 2001 From: Romain Menke Date: Tue, 21 Nov 2023 11:08:47 +0100 Subject: [PATCH 2/2] fix stackoverflow --- http/interceptor.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http/interceptor.go b/http/interceptor.go index a7b616ab5..2f3352e97 100644 --- a/http/interceptor.go +++ b/http/interceptor.go @@ -109,7 +109,7 @@ func (i *rwInterceptor) Header() http.Header { } func (i *rwInterceptor) ReadFrom(r io.Reader) (n int64, err error) { - return io.Copy(i, r) + return io.Copy(struct{ io.Writer }{i}, r) } func (i *rwInterceptor) Flush() {