0
0
Fork 0
mirror of https://github.com/matrix-org/dendrite synced 2024-09-24 20:08:57 +02:00

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)`.
This commit is contained in:
Neil Alexander 2022-02-17 13:25:41 +00:00 committed by GitHub
parent 89b7519089
commit 353168a9e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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