Skip to content

Commit 931c3c8

Browse files
committed
[bitreq] Use saturating_add for chunked content-length accumulation
Use saturating_add instead of += when accumulating content_length in chunked transfer encoding. This prevents integer overflow on 32-bit systems where a malicious server could send chunk sizes that cause the accumulated length to wrap around. Co-Authored-By: Claude AI
1 parent 3964cc7 commit 931c3c8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

bitreq/src/response.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ macro_rules! define_read_methods {
584584
return None;
585585
}
586586
*chunk_length = incoming_length;
587-
*content_length += incoming_length;
587+
*content_length = content_length.saturating_add(incoming_length);
588588
}
589589

590590
if *chunk_length > 0 {

0 commit comments

Comments
 (0)