Skip to content

Comments

gibblox: add GptBlockReader#6

Open
samcday wants to merge 2 commits intomainfrom
gibblox-gpt
Open

gibblox: add GptBlockReader#6
samcday wants to merge 2 commits intomainfrom
gibblox-gpt

Conversation

@samcday
Copy link
Owner

@samcday samcday commented Feb 15, 2026

No description provided.

@samcday
Copy link
Owner Author

samcday commented Feb 15, 2026

@codex hows about you review your own work how about that let's see huh what about it

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2d0d134236

ℹ️ 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".

let mut scratch = vec![0u8; aligned_len];
let mut filled = 0usize;
while filled < scratch.len() {
let lba = (aligned_start as usize + filled) / self.block_size;

Choose a reason for hiding this comment

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

P1 Badge Keep LBA math in u64 when deriving source offsets

SourceByteReader::read_exact_at computes lba via (aligned_start as usize + filled) / self.block_size, which truncates aligned_start on 32-bit targets (notably wasm32). For GPT images whose reads cross the 4GiB boundary, this causes reads from the wrong source blocks while still returning success, so partition data becomes silently corrupted. Perform this arithmetic in u64 and only downcast with checked conversions where required.

Useful? React with 👍 / 👎.

Comment on lines +370 to +372
let partition_entries_lba = read_u64_le(raw, 72)?;
let partition_entry_count = read_u32_le(raw, 80)?;
let partition_entry_size = read_u32_le(raw, 84)?;

Choose a reason for hiding this comment

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

P2 Badge Validate GPT header and entry-array CRCs

The GPT parser reads structural fields but never validates the header CRC32 (offset 16) or partition-entry-array CRC32 (offset 88), so corrupted or stale GPT metadata can still be accepted and used to resolve a partition. In a range-backed reader this can select the wrong partition bytes without any error, so integrity checks should happen before trusting partition_entries_lba, partition_entry_count, and related fields.

Useful? React with 👍 / 👎.

@samcday samcday mentioned this pull request Feb 21, 2026
Signed-off-by: Sam Day <me@samcday.com>
Assisted-by: opencode:gpt-5.3-codex
Signed-off-by: Sam Day <me@samcday.com>
Assisted-by: opencode:gpt-5.3-codex
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.

1 participant