From f0b0a6572ff7908c890963f6462af27dcef80bd7 Mon Sep 17 00:00:00 2001 From: Ryan Lahfa Date: Thu, 18 Jul 2024 21:47:09 +0200 Subject: [PATCH] fix(tvix/nix-compat): use `buf.filled()` to track read bytes We were wrongly using `buf.initialized()` which contains more than the filled portion to compute the number of bytes read during a poll call. This made us go into the trailer reading state too early and finally failing due to invalid trailer data. Fixes b/405. Co-authored-by: Florian Klink Change-Id: I66ba6e2116389e6b97305f85c4e0922195000e45 Signed-off-by: Ryan Lahfa Reviewed-on: https://cl.tvl.fyi/c/depot/+/11978 Tested-by: BuildkiteCI Reviewed-by: flokli Reviewed-by: edef --- tvix/nix-compat/src/wire/bytes/reader/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tvix/nix-compat/src/wire/bytes/reader/mod.rs b/tvix/nix-compat/src/wire/bytes/reader/mod.rs index c0227f4e6..81474df70 100644 --- a/tvix/nix-compat/src/wire/bytes/reader/mod.rs +++ b/tvix/nix-compat/src/wire/bytes/reader/mod.rs @@ -152,7 +152,7 @@ impl AsyncRead for BytesReader { let mut bytes_read = 0; ready!(with_limited(buf, remaining, |buf| { let ret = reader.poll_read(cx, buf); - bytes_read = buf.initialized().len(); + bytes_read = buf.filled().len(); ret }))?;