From 353168a9e93803bc9c5608d2e0ec55ba7fc581d9 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Thu, 17 Feb 2022 13:25:41 +0000 Subject: [PATCH] Fix potential panic in `NewStreamTokenFromString` caused by off-by-one error (#2196) Line 291 could panic when trying to set `positions[i]` if `i == len(positions)`. --- syncapi/types/types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syncapi/types/types.go b/syncapi/types/types.go index 68c308d8..c2e8ed01 100644 --- a/syncapi/types/types.go +++ b/syncapi/types/types.go @@ -279,7 +279,7 @@ func NewStreamTokenFromString(tok string) (token StreamingToken, err error) { parts := strings.Split(tok[1:], "_") var positions [7]StreamPosition for i, p := range parts { - if i > len(positions) { + if i >= len(positions) { break } var pos int