Skip to content

fix(osc): guard params[1] access in OSC 1337 arm against missing second param#12872

Open
adhavan18 wants to merge 1 commit into
warpdotdev:masterfrom
adhavan18:fix/osc-1337-params-bounds-check
Open

fix(osc): guard params[1] access in OSC 1337 arm against missing second param#12872
adhavan18 wants to merge 1 commit into
warpdotdev:masterfrom
adhavan18:fix/osc-1337-params-bounds-check

Conversation

@adhavan18

Copy link
Copy Markdown

Description

adds a params.len() < 2 guard at the top of the b"1337" arm in osc_dispatch so a parameterless OSC 1337 sequence is treated as unhandled instead of panicking.

Linked Issue

  • The linked issue is labeled ready-to-spec or ready-to-implement.

fixes #12817

Root cause

app/src/terminal/model/ansi/mod.rs, osc_dispatch, the b"1337" arm directly accesses params[1] without a length guard. every neighboring OSC arm (133, 777, 52, 9277, 9278) checks params.len() before accessing any param beyond index 0 — the 1337 arm was the only exception.

when the sequence has no second parameter (params == [b"1337"]), params[1] is out of bounds → panic.

Fix

three lines added at the top of the b"1337" arm:

if params.len() < 2 {
    return unhandled(params);
}

this is identical to the guard pattern already used by b"133", b"777", b"52", and others.

Testing

  • I have manually tested my changes locally with ./script/run

added a regression unit test in mod_tests.rs:

#[test]
fn parse_osc1337_without_second_param_does_not_panic() {
    let bytes: &[u8] = b"\x1b]1337\x07";
    let _ = parse_bytes(bytes); // must not panic
}

manual test: printf '\e]1337\a' in a running warp session no longer crashes.

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

CHANGELOG-BUG-FIX: fix panic when receiving a bare OSC 1337 sequence without a second parameter

…nd param (warpdotdev#12817)

a bare 'ESC ] 1337 BEL' (no second parameter) caused an index-out-of-bounds
panic because the 1337 arm accessed params[1] unconditionally.

every neighboring OSC arm (133, 777, 52, 9277, 9278...) already checks
params.len() before accessing params[1]. the 1337 arm was the only exception.

fix: add a params.len() < 2 early-return to unhandled() at the top of the
1337 arm, exactly mirroring the pattern used by all surrounding arms.

adds a regression test: parsing 'ESC ] 1337 BEL' must not panic.
@cla-bot

cla-bot Bot commented Jun 21, 2026

Copy link
Copy Markdown

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @adhavan18 on file. In order for us to review and merge your code, each contributor must visit https://cla.warp.dev to read and agree to our CLA. Once you have done so, please comment @cla-bot check to trigger another check.

@github-actions github-actions Bot added the external-contributor Indicates that a PR has been opened by someone outside the Warp team. label Jun 21, 2026
@oz-for-oss

oz-for-oss Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

@adhavan18

Every PR must be linked to a same-repo issue before Oz can review it.

This PR is linked to #12817, but no linked issue is marked ready-to-implement yet. Only repository maintainers apply that label, so please wait for a maintainer to mark the issue. Once it is marked, push a new commit or comment /oz-review to re-trigger review.

See the contribution guidelines for the full readiness model.

Powered by Oz

@oz-for-oss oz-for-oss Bot 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.

@adhavan18

Every PR must be linked to a same-repo issue before Oz can review it.

This PR is linked to #12817, but no linked issue is marked ready-to-implement yet. Only repository maintainers apply that label, so please wait for a maintainer to mark the issue. Once it is marked, push a new commit or comment /oz-review to re-trigger review.

See the contribution guidelines for the full readiness model.

Powered by Oz

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

Labels

external-contributor Indicates that a PR has been opened by someone outside the Warp team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OSC 1337 without a second parameter panics (index out of bounds), crashing terminal output processing

1 participant