check SplitN() return value to prevent indexing beyond end of slice

This commit is contained in:
Larry Ruane 2021-01-14 15:39:26 -07:00 committed by Larry Ruane
parent ad739ce055
commit 824cb8dc8e
1 changed files with 3 additions and 0 deletions

View File

@ -304,6 +304,9 @@ func (s *lwdStreamer) SendTransaction(ctx context.Context, rawtx *walletrpc.RawT
// For some reason, the error responses are not JSON
if rpcErr != nil {
errParts := strings.SplitN(rpcErr.Error(), ":", 2)
if len(errParts) < 2 {
return nil, errors.New("SendTransaction couldn't parse error code")
}
errMsg = strings.TrimSpace(errParts[1])
errCode, err = strconv.ParseInt(errParts[0], 10, 32)
if err != nil {