Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent overflow of int values #89

Merged
merged 10 commits into from
Dec 2, 2024
Merged

Conversation

fabiobozzo
Copy link
Collaborator

@fabiobozzo fabiobozzo commented Nov 29, 2024

This PR adds JavaScript-safe integer bounds checking (±2^53-1) across the policy package. This ensures all integer operations remain within JavaScript's safe integer bounds, preventing potential overflow issues while maintaining UCAN spec compliance.

Changes

  • Added shared integer limits constants in pkg/internal/limits
  • Added bounds checking for integer comparisons in policy matching
  • Added validation for slice/index parsing in selectors
  • Added overflow protection for integer-to-IPLD conversion
  • Added comprehensive overflow test cases

@fabiobozzo fabiobozzo linked an issue Nov 29, 2024 that may be closed by this pull request
pkg/policy/match.go Outdated Show resolved Hide resolved
@MichaelMure MichaelMure merged commit 78d37d9 into main Dec 2, 2024
6 checks passed
@MichaelMure MichaelMure deleted the fix/prevent-int-overflow branch December 2, 2024 13:41
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.

Prevent overflow of int values
2 participants