about summary refs log tree commit diff
path: root/tvix/nix-compat/src/wire
diff options
context:
space:
mode:
authorRyan Lahfa <tvl@lahfa.xyz>2024-07-18T19·47+0200
committerraitobezarius <tvl@lahfa.xyz>2024-07-18T22·13+0000
commitf0b0a6572ff7908c890963f6462af27dcef80bd7 (patch)
treebef600f4c94fd0f999c5934884071b83d32a2377 /tvix/nix-compat/src/wire
parent168e4fda5909e535f33051051ef426e221ef20d4 (diff)
fix(tvix/nix-compat): use `buf.filled()` to track read bytes r/8369
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 <flokli@flokli.de>
Change-Id: I66ba6e2116389e6b97305f85c4e0922195000e45
Signed-off-by: Ryan Lahfa <tvl@lahfa.xyz>
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11978
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
Reviewed-by: edef <edef@edef.eu>
Diffstat (limited to 'tvix/nix-compat/src/wire')
-rw-r--r--tvix/nix-compat/src/wire/bytes/reader/mod.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/tvix/nix-compat/src/wire/bytes/reader/mod.rs b/tvix/nix-compat/src/wire/bytes/reader/mod.rs
index c0227f4e6cff..81474df70657 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<R: AsyncRead + Unpin, T: Tag> AsyncRead for BytesReader<R, T> {
                     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
                     }))?;