Skip to content

fix(network): use try_from instead of truncating u64-to-usize cast#472

Merged
chaliy merged 1 commit intomainfrom
claude/fix-430-Y2nIj
Mar 2, 2026
Merged

fix(network): use try_from instead of truncating u64-to-usize cast#472
chaliy merged 1 commit intomainfrom
claude/fix-430-Y2nIj

Conversation

@chaliy
Copy link
Contributor

@chaliy chaliy commented Mar 2, 2026

Summary

  • content_length as usize and limit casts silently truncate on 32-bit platforms
  • Changed to usize::try_from().unwrap_or(usize::MAX) for safe saturation

Test plan

  • Unit test: test_u64_to_usize_no_truncation

Closes #430

Replace `u64 as usize` casts with `usize::try_from().unwrap_or(usize::MAX)`
in network client (content_length) and Python bindings (limits).
Prevents silent truncation on 32-bit platforms.

Closes #430
@chaliy chaliy force-pushed the claude/fix-430-Y2nIj branch from 1898b4d to aaa0a95 Compare March 2, 2026 02:53
@chaliy chaliy merged commit daff491 into main Mar 2, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[L-6] Integer truncation on 32-bit platforms

2 participants