From f387547749c72a712c99b61236735e00ee93e723 Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Thu, 14 Mar 2024 22:14:48 +0100 Subject: [PATCH] Add sanity check for split strings in password handling In order to avoid potential indexing issues in password handling, a conditional statement has been added. This ensures that there are two resultant parts after the string splitting operation; if the condition isn't met, the operation simply continues without processing further. This enhances code robustness and reliability. --- password.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/password.go b/password.go index 319a143..36ab11f 100644 --- a/password.go +++ b/password.go @@ -205,6 +205,9 @@ func (p *PwnedPassAPI) ListHashesPrefix(pf string) ([]Match, *http.Response, err so := bufio.NewScanner(hr.Body) for so.Scan() { hp := strings.SplitN(so.Text(), ":", 2) + if len(hp) != 2 { + continue + } fh := fmt.Sprintf("%s%s", strings.ToLower(pf), strings.ToLower(hp[0])) hc, err := strconv.ParseInt(hp[1], 10, 64) if err != nil {