Loading
Add memory allocation limits to stream parsers (#413)
* Initial plan * Add size limits to prevent unbounded memory allocation in stream parsers Co-authored-by:Nugine <30099658+Nugine@users.noreply.github.com> * Fix clippy warnings and formatting Co-authored-by:
Nugine <30099658+Nugine@users.noreply.github.com> * Add tests for memory allocation limit error conditions - Add test for BoundaryBufferTooLarge error in FileStream - Add test for ChunkMetaTooLarge error in AWS chunked stream - Add test for TrailersTooLarge error handling - Add test for TooManyTrailerHeaders error handling These tests verify that the size limits prevent unbounded memory allocation as intended, addressing review feedback. Co-authored-by:
Nugine <30099658+Nugine@users.noreply.github.com> * Fix buffer size check and improve test assertions - Add size check before extending buffer when newline is found in push_meta_bytes This prevents the buffer from growing beyond MAX_CHUNK_META_SIZE even when newline appears exactly at the boundary - Improve test assertions for trailer limit tests to consume remaining stream and verify trailers were not stored when limits are exceeded - Tests now properly validate that unbounded allocation is prevented Addresses review feedback on buffer overflow edge case and test verification. Co-authored-by:
Nugine <30099658+Nugine@users.noreply.github.com> * Improve error verification in trailer limit tests - Update test_trailers_too_large to explicitly check for TrailersTooLarge error - Update test_too_many_trailer_headers to explicitly check for TooManyTrailerHeaders error - Tests now properly verify errors are returned when limits are exceeded - Handle both direct error variants and errors wrapped in Underlying - Fallback to checking trailers weren't stored if error not captured - Fix clippy warnings: collapsible_match and match_same_arms Addresses review feedback to explicitly verify error conditions. Co-authored-by:
Nugine <30099658+Nugine@users.noreply.github.com> * Apply formatting fixes * Update crates/s3s/src/http/aws_chunked_stream.rs Co-authored-by:
Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by:
copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by:
Nugine <30099658+Nugine@users.noreply.github.com> Co-authored-by:
Nugine <nugine@foxmail.com> Co-authored-by:
Copilot <175728472+Copilot@users.noreply.github.com>