Skip to content

noq-proto: fix CID exhaustion check overflow on 32-bit targets#564

Merged
flub merged 1 commit inton0-computer:mainfrom
KevinRoebert:main
Apr 3, 2026
Merged

noq-proto: fix CID exhaustion check overflow on 32-bit targets#564
flub merged 1 commit inton0-computer:mainfrom
KevinRoebert:main

Conversation

@KevinRoebert
Copy link
Copy Markdown
Contributor

Summary

Fixes an overflow in Endpoint::cids_exhausted() on 32-bit targets when CID length is 4.

The previous check used usize exponentiation:

  • 2usize.pow(cid_len * 8) overflows for cid_len == 4 on 32-bit platforms (2^32 does not fit in usize).

This change is already merged into quinn: quinn-rs/quinn#2533

Changes

  • Replaced the exhaustion arithmetic with an overflow-safe implementation using u64.

Notes

  • Kept the same exhaustion threshold semantics (>3/4 used).
  • Preserved the early return behavior for cid_len == 0 and cid_len > 4.
  • No behavior change is intended on 64-bit targets.
  • Arithmetic is now architecture-independent.

@n0bot n0bot bot added this to iroh Apr 2, 2026
@github-project-automation github-project-automation bot moved this to 🚑 Needs Triage in iroh Apr 2, 2026
Copy link
Copy Markdown
Collaborator

@flub flub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

We do need to merge Quinn's changes into noq again sometime soon. And really need to set up a more structured approach to that.

@flub flub added this pull request to the merge queue Apr 3, 2026
Merged via the queue into n0-computer:main with commit 93f4216 Apr 3, 2026
35 of 36 checks passed
@github-project-automation github-project-automation bot moved this from 🚑 Needs Triage to ✅ Done in iroh Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

2 participants