Address CWE-703 in hibp.go

This commit is contained in:
eikendev 2023-02-11 23:58:47 +01:00
parent ead4f364f7
commit 64563989b5
No known key found for this signature in database
GPG key ID: A1BDB1B28C8EF694

View file

@ -39,12 +39,16 @@ func IsPasswordPwned(password string) (bool, error) {
log.L.Fatalf("Request failed with HTTP %s.", resp.Status)
}
defer resp.Body.Close()
bodyText, err := io.ReadAll(resp.Body)
if err != nil {
log.L.Fatal(err)
}
err = resp.Body.Close()
if err != nil {
log.L.Warnf("Failed to close file: %s.", err)
}
bodyStr := string(bodyText)
lines := strings.Split(bodyStr, "\n")