Skip to content

32-bit targets: arithmetic on file-derived lengths can wrap past a bounds check (wasm32, found by #835) #836

Closed

Description

@DrunkOnJava

#835 found a parser panic that only a 32-bit target can reach. A UTF-16 string field's end was 4 + char_count.saturating_mul(2). On wasm32 usize is 32 bits, so a corrupt char_count saturates to usize::MAX, the addition wraps to 3 in a release build, the bounds check passes and &slice[4..3] panics. In the browser viewer that aborts the whole export.

Native builds cannot reach it, because a u32 length times 2 fits a 64-bit usize. So no CI job, fuzz target or corpus run sees this class: every one of them runs on 64-bit. Any sum or product of file-derived lengths in usize that a 64-bit build cannot overflow can still wrap on wasm32, the target the viewer ships on, and on any other 32-bit build.

What was checked so far: the other saturating_mul calls in src/ are clamped (compression.rs, by .min() straight after) or compared with a cap (partition_pipe_axes.rs), so they cannot wrap into a bounds check.

What would close this: run the integration tests, and replay the fuzz regressions, on a 32-bit target with overflow checks on, so a wrap panics instead of passing a check. For example, a CI job on i686-unknown-linux-gnu with -C overflow-checks=on under --profile ci. Then fix each site it reports with checked arithmetic, as #835 does.

Activity

  1. added
    area:reader
    priority:P2
    type:bug
    on Oct 19, 2026
  2. DrunkOnJava commented on Oct 20, 2026

    @DrunkOnJava
    OwnerAuthor

    Shipped in v0.6.1: both wraps the i686 job found (#839), on crates.io and PyPI. The browser viewer, built from main, has had them since #839 merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:readerpriority:P2type:bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions