Skip to content

fix(encode): 32-bit safe pack header check#64

Merged
genedna merged 1 commit into
libra-tools:mainfrom
yueneiqi:fix/encode-32bit-check
Jan 4, 2026
Merged

fix(encode): 32-bit safe pack header check#64
genedna merged 1 commit into
libra-tools:mainfrom
yueneiqi:fix/encode-32bit-check

Conversation

@yueneiqi

@yueneiqi yueneiqi commented Jan 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • replace shift-based upper bound with u32::MAX to avoid 32-bit overflow
  • keep the pack header object count check equivalent and portable

Testing

  • cargo build --target i686-unknown-linux-gnu

This PR was primarily authored with Codex using GPT-5.2-Codex and then hand-reviewed by me. I AM responsible for every change made in this PR. I aimed to keep it aligned with our goals, though I may have missed minor issues. Please flag anything that feels off, I'll fix it quickly.

Signed-off-by: linfeng.ouyang <fyoylf@gmail.com>
@genedna

genedna commented Jan 4, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a 32-bit platform overflow issue in the pack header encoding logic by replacing a shift-based upper bound check with an explicit u32::MAX comparison.

Key Changes

  • Replaced assert!(object_number < (1 << 32)) with assert!(object_number <= u32::MAX as usize) to avoid overflow on 32-bit platforms while maintaining equivalent semantics

@genedna
genedna merged commit a8adb06 into libra-tools:main Jan 4, 2026
14 checks passed
yueneiqi added a commit to yueneiqi/git-internal that referenced this pull request Jan 4, 2026
Signed-off-by: linfeng.ouyang <fyoylf@gmail.com>
@github-actions github-actions Bot mentioned this pull request Feb 12, 2026
genedna pushed a commit to genedna/git-internal that referenced this pull request Mar 15, 2026
Signed-off-by: linfeng.ouyang <fyoylf@gmail.com>
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.

3 participants