Skip to content

fix: refuse HEIC plane copy when decode size mismatches handle (#14) - #56

Merged
McanKul merged 1 commit into
McanKul:developmentfrom
nonamexishere:feat/14-heic-import-crash
Aug 25, 2026
Merged

fix: refuse HEIC plane copy when decode size mismatches handle (#14)#56
McanKul merged 1 commit into
McanKul:developmentfrom
nonamexishere:feat/14-heic-import-crash

Conversation

@nonamexishere

Copy link
Copy Markdown
Contributor

Summary

Addresses #14: HEIC/HEIF import can ACCESS_VIOLATE on real phone photos after #29 and #49.

After heif_decode_image, OffPDF now inspects the decoded interleaved plane (width/height/chroma/bpp) and refuses to copy if it does not match the handle-sized output buffer. copy_pixels sizes rows from the plane. Decode requests 8-bit conversion when options can be allocated.

This branch is from development only. It does not include #54 or #55.

In scope

  • Remaining handle-vs-plane copy unsoundness (grid / irot stand-ins)
  • Invalid/truncated/oversized files still return AppError
  • Synthetic HEIC/HEIF still convert to a one-page PDF
  • RGBA 32-bpp-like fixture convert-or-INVALID_IMAGE

Out of scope

Why

#49 validated stride and dest length using handle dimensions. A shorter or swapped plane can still pass stride >= row and then read off the buffer (0xc0000005 on Windows).

Validation

  • npm run typecheck
  • npm test (179)
  • cargo test --manifest-path src-tauri/Cargo.toml --lib (97)
  • cargo test -p heif-rs --manifest-path src-tauri/Cargo.toml --lib
  • Manual macOS HEIC/HEIF import, garbage, truncated, and batch (app stayed up)

Privacy Checklist

  • This keeps OffPDF usable offline.
  • This does not upload, log, or transmit user files.
  • New dependencies or bundled binaries have compatible licenses.

After heif_decode_image, compare interleaved plane width/height to the
handle before any copy. Mismatched grid/irot layouts return INVALID_IMAGE
instead of reading off the plane (Windows 0xc0000005). Fixes McanKul#14.
@McanKul
McanKul merged commit ec298a9 into McanKul:development Aug 25, 2026
2 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.

2 participants