From 451f4c2a8f2d9f00d19bf8a73d7291958fe89e9c Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 13 Apr 2023 11:14:10 +0100 Subject: [PATCH] onedrive: fix quickxorhash on 32 bit architectures Before this fix quickxorhash would sometimes crash with an error like this: panic: runtime error: slice bounds out of range [-1248:] This was caused by an incorrect cast of a 64 bit number to a 32 bit one on 32 bit platforms. See: https://forum.rclone.org/t/panic-runtime-error-slice-bounds-out-of-range/37548 --- backend/onedrive/quickxorhash/quickxorhash.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/onedrive/quickxorhash/quickxorhash.go b/backend/onedrive/quickxorhash/quickxorhash.go index 242d704f1..a8fa3d7f0 100644 --- a/backend/onedrive/quickxorhash/quickxorhash.go +++ b/backend/onedrive/quickxorhash/quickxorhash.go @@ -61,7 +61,7 @@ func New() hash.Hash { func (q *quickXorHash) Write(p []byte) (n int, err error) { var i int // fill last remain - lastRemain := int(q.size) % dataSize + lastRemain := q.size % dataSize if lastRemain != 0 { i += xorBytes(q.data[lastRemain:], p) }