Skip to content

Commit 3feab60

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 77d9d03 commit 3feab60

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
@@ -576,7 +576,7 @@ macro_rules! define_read_methods {
576576
return None;
577577
}
578578
*chunk_length = incoming_length;
579-
*content_length += incoming_length;
579+
*content_length = content_length.saturating_add(incoming_length);
580580
}
581581

582582
if *chunk_length > 0 {

0 commit comments

Comments
 (0)