From c1146d98f37e48106b91193e5eb0db1edf19e43c Mon Sep 17 00:00:00 2001 From: crimike Date: Fri, 1 Sep 2023 16:38:55 +0200 Subject: [PATCH 1/3] fix: resource/socket exhaustion --- client/rest/utils.go | 1 + 1 file changed, 1 insertion(+) diff --git a/client/rest/utils.go b/client/rest/utils.go index 543eaa4..b61c416 100644 --- a/client/rest/utils.go +++ b/client/rest/utils.go @@ -35,6 +35,7 @@ import ( func Decode(body io.ReadCloser, v interface{}) error { defer body.Close() + defer ioutil.ReadAll(body) return json.NewDecoder(body).Decode(v) } From 5dc2e38cf833c64de2831e71c42ff2f239c936d6 Mon Sep 17 00:00:00 2001 From: crimike Date: Fri, 1 Sep 2023 17:08:22 +0200 Subject: [PATCH 2/3] fix: missing import --- client/rest/utils.go | 1 + 1 file changed, 1 insertion(+) diff --git a/client/rest/utils.go b/client/rest/utils.go index b61c416..9d319db 100644 --- a/client/rest/utils.go +++ b/client/rest/utils.go @@ -25,6 +25,7 @@ import ( "encoding/pem" "fmt" "io" + "io/ioutil" "strings" "time" From 32c61fef637eaf38ef810b528cb597a2ed7abef8 Mon Sep 17 00:00:00 2001 From: Dillon Lees Date: Fri, 1 Sep 2023 12:45:39 -0400 Subject: [PATCH 3/3] chore: replace ioutil.readall with io.readall --- client/rest/utils.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client/rest/utils.go b/client/rest/utils.go index 9d319db..b048e7b 100644 --- a/client/rest/utils.go +++ b/client/rest/utils.go @@ -25,7 +25,6 @@ import ( "encoding/pem" "fmt" "io" - "io/ioutil" "strings" "time" @@ -36,7 +35,7 @@ import ( func Decode(body io.ReadCloser, v interface{}) error { defer body.Close() - defer ioutil.ReadAll(body) + defer io.ReadAll(body) // must read all; streaming to the json decoder does not read to EOF making the connection unavailable for reuse return json.NewDecoder(body).Decode(v) }