Skip to content

Commit f75dfcb

Browse files
committed
Bound Tokio limited-helper cleanup cost
1 parent 7e6aa96 commit f75dfcb

5 files changed

Lines changed: 15 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
buffers and RAII-wiped read-all allocations that also cover cancellation.
2424
- Bounded Tokio limited-helper over-read to one lookahead byte and documented
2525
the adjacent-frame contract.
26+
- Capped Tokio limited-helper eager allocation at 8 KiB and made per-read
27+
staging cleanup proportional to bytes received while retaining full RAII
28+
cleanup on cancellation and drop.
2629
- Pinned documented release-tool installs to the audited current versions,
2730
including cargo-nextest `0.9.140` and cargo-fuzz `0.13.2`.
2831
- Deferred the stronger RISC-V RVV proof and backend-admission review to

crates/base64-ng-tokio/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ or validate a final partial quantum.
3636
Read-all helper allocations are RAII-wiped on success, error, and cancellation.
3737
Limited helpers consume no more than the configured limit plus one lookahead
3838
byte used to detect overflow. Use a separately bounded reader or a streaming
39-
adapter when an adjacent frame's first byte must remain unread.
39+
adapter when an adjacent frame's first byte must remain unread. Their eager
40+
allocation is capped at 8 KiB so cleanup work stays proportional to accepted
41+
input rather than the caller's maximum alone.
4042

4143
```rust
4244
use base64_ng::STANDARD;

crates/base64-ng-tokio/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub use readers::{DecoderReader, EncoderReader};
3939
use base64_ng::{Alphabet, Engine};
4040
use tokio::io::{self, AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
4141

42-
const READ_ALL_EAGER_CAP: usize = 1024 * 1024;
42+
const READ_ALL_EAGER_CAP: usize = 8192;
4343

4444
/// Reads all bytes from `reader`, encodes them, and writes the encoded output.
4545
///
@@ -287,6 +287,6 @@ where
287287
}
288288

289289
input.0.extend_from_slice(&chunk.0[..read]);
290-
wipe_bytes(&mut chunk.0);
290+
wipe_bytes(&mut chunk.0[..read]);
291291
}
292292
}

docs/ASYNC.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ suspension point. Their initialized bytes and spare capacity are wiped on
1717
success, I/O error, or future cancellation. Limited helpers request at most the
1818
remaining allowance plus one lookahead byte. Generic `AsyncRead` cannot return
1919
that lookahead byte to the source; callers that must preserve adjacent framed
20-
input should provide an already bounded reader or use a streaming adapter.
20+
input should provide an already bounded reader or use a streaming adapter. The
21+
limited helpers cap eager allocation at 8 KiB and wipe only the bytes filled by
22+
each successful read; their RAII guards still wipe complete live allocations
23+
and the complete staging array on cancellation or drop.
2124

2225
## Current Status
2326

release-notes/RELEASE_NOTES_1.3.7.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ the `base64-ng` crate family.
2626
wipe through RAII on success, error, and cancellation.
2727
- Limited oversized-input detection to one lookahead byte and documented the
2828
adjacent-frame behavior for generic `AsyncRead` sources.
29+
- Capped limited-helper eager allocation at 8 KiB and made per-read staging
30+
cleanup proportional to received input while retaining full cancellation
31+
cleanup.
2932
- Pinned documented release/deep-check tool versions to the current audited
3033
releases, including cargo-nextest `0.9.140` and cargo-fuzz `0.13.2`.
3134
- Scheduled the stronger RISC-V RVV proof and backend-admission review for

0 commit comments

Comments
 (0)