Skip to content

A non-UTF-8 argv byte aborts the process: std::env::args() unwraps instead of args_os() #9401

Description

@proggeramlug
claude -p $'\xff\xfe\x80abc\xc3\x28'
  node : rc=1   "Not logged in · Please run /login"
  perry: rc=134 (SIGABRT)
         thread '<unnamed>' panicked at library/std/src/env.rs:878:51:
         called `Result::unwrap()` on an `Err` value: "\xFF\xFE\x80abc\xC3("

std::env::args() panics on any argument that is not valid UTF-8. Non-UTF-8 filenames are ordinary on Linux, so this is reachable by a user simply passing a path, and the panic text leaks Rust internals into the program's stderr.

Fix: use std::env::args_os() and convert lossily (or preserve the bytes) at the boundary, matching node, which accepts the argument and proceeds.

A grep for env::args() elsewhere in the runtime is worthwhile — the same unwrap pattern may appear on other paths.

Found by a differential stress-test of cc 2.1.112 under perry 757beace0.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions