From 6604ce4e512208ec559c5c0b295fbe14fcac87cf Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Fri, 30 Jun 2023 13:50:14 +0200 Subject: fix(tvix/store/blobservice): write into hasher from b, not buf buf contains everything written so far, whereas b is the slice passed in the current write() call. If we copy from &buf, we end up with the wrong hash, because we keep writing the wrong data to the hash function. Change-Id: I768d4645934a6a7d75b9c8eeba35f8f3be5edd26 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8880 Reviewed-by: tazjin Tested-by: BuildkiteCI Autosubmit: flokli --- tvix/store/src/blobservice/memory.rs | 2 +- tvix/store/src/blobservice/sled.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tvix/store/src/blobservice/memory.rs b/tvix/store/src/blobservice/memory.rs index a53f899149..244055258e 100644 --- a/tvix/store/src/blobservice/memory.rs +++ b/tvix/store/src/blobservice/memory.rs @@ -79,7 +79,7 @@ impl std::io::Write for MemoryBlobWriter { )), Some((ref mut buf, ref mut hasher)) => { let bytes_written = buf.write(b)?; - hasher.write(&buf[..bytes_written]) + hasher.write(&b[..bytes_written]) } } } diff --git a/tvix/store/src/blobservice/sled.rs b/tvix/store/src/blobservice/sled.rs index 2b8f9e7bbb..22dcd757f2 100644 --- a/tvix/store/src/blobservice/sled.rs +++ b/tvix/store/src/blobservice/sled.rs @@ -108,7 +108,7 @@ impl io::Write for SledBlobWriter { )), Some((ref mut buf, ref mut hasher)) => { let bytes_written = buf.write(b)?; - hasher.write(&buf[..bytes_written]) + hasher.write(&b[..bytes_written]) } } } -- cgit 1.4.1