From ffb97994020c0a6276240cdec36f935bc1462c8c Mon Sep 17 00:00:00 2001 From: verse91 Date: Sun, 10 May 2026 01:14:12 +0700 Subject: [PATCH] chore(update): check the HTTP response status code before reading the body --- root/update.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/root/update.go b/root/update.go index ae286e6..3ae242b 100644 --- a/root/update.go +++ b/root/update.go @@ -90,6 +90,10 @@ func FetchLatestVersion() (string, error) { } defer func() { _ = resp.Body.Close() }() + if resp.StatusCode != http.StatusOK { + return "", fmt.Errorf("unexpected status code: %d", resp.StatusCode) + } + body, err := io.ReadAll(resp.Body) if err != nil { return "", err