proofs.rs

Pointer::get overflows when the excluded start bound is usize::MAX

Pointer::get overflows when the excluded start bound is usize::MAX

Found in Report #41 v1 · Updated 2026-11-28 01:04 UTC

Description

Pointer::get can panic or return the wrong slice when a tuple of bounds
uses Excluded(usize::MAX) as its start bound.

Steps to Reproduce

Use jsonptr 0.8.2 and run the example with both cargo run and
cargo run --release.

use jsonptr::Pointer;
use std::ops::Bound::{Excluded, Unbounded};

fn main() {
    let pointer = Pointer::from_static("/one/two");
    let result = pointer.get((Excluded(usize::MAX), Unbounded));
    assert_eq!(result, None);
}
Expected Behavior

The call returns None because no token index can exceed usize::MAX.

Actual Behavior

The default debug build panics with attempt to add with overflow.
The default release build returns Some containing "/one/two" and the
assertion fails.

Environment

Rust 1.91.0 on aarch64 macOS. No optional jsonptr features are needed.

Change history
  1. v1 · created · 2026-11-28 01:04 UTC
    {
      "title": "Pointer::get overflows when the excluded start bound is usize::MAX",
      "body": "## Description\n\n`Pointer::get` can panic or return the wrong slice when a tuple of bounds\nuses `Excluded(usize::MAX)` as its start bound.\n\n## Steps to Reproduce\n\nUse jsonptr 0.8.2 and run the example with both `cargo run` and\n`cargo run --release`.\n\n```rust\nuse jsonptr::Pointer;\nuse std::ops::Bound::{Excluded, Unbounded};\n\nfn main() {\n    let pointer = Pointer::from_static(\"/one/two\");\n    let result = pointer.get((Excluded(usize::MAX), Unbounded));\n    assert_eq!(result, None);\n}\n```\n\n## Expected Behavior\n\nThe call returns `None` because no token index can exceed `usize::MAX`.\n\n## Actual Behavior\n\nThe default debug build panics with `attempt to add with overflow`.\nThe default release build returns `Some` containing `\"/one/two\"` and the\nassertion fails.\n\n## Environment\n\nRust 1.91.0 on aarch64 macOS. No optional jsonptr features are needed.",
      "validity": "reported",
      "upstream_status": "not_reported"
    }

Read and join the discussion on the report →