From 2b720be3891495ee6af3032991e97c4262181b18 Mon Sep 17 00:00:00 2001 From: Marco Pfatschbacher Date: Fri, 13 Oct 2023 17:10:04 +0100 Subject: [PATCH] dont try to json parse arbitrary http error responses --- api/rest/rest.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/api/rest/rest.go b/api/rest/rest.go index 41dffa5a..f8e05f86 100644 --- a/api/rest/rest.go +++ b/api/rest/rest.go @@ -149,12 +149,9 @@ func CheckResponse(r *http.Response) error { } errorResponse := &ErrorResponse{Response: r} - data, err := ioutil.ReadAll(r.Body) + data, err := io.ReadAll(io.LimitReader(r.Body, 2048)) if err == nil && len(data) > 0 { - err := json.Unmarshal(data, errorResponse) - if err != nil { - return err - } + errorResponse.Message = string(data) } return errorResponse