Skip to content

Nixsa doesn't work with non-UTF-8 paths #32

@alurm

Description

@alurm
$ RUST_BACKTRACE=1 nixsa "$(printf '\777')"
thread 'main' panicked at std/src/env.rs:867:51:
called `Result::unwrap()` on an `Err` value: "\xFF"
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::result::unwrap_failed
   3: <std::env::Args as core::iter::traits::iterator::Iterator>::next
   4: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
   5: nixsa::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Here's an example of why this is an issue: paths don't have to be valid UTF-8. Since we're wrapping arbitrary programs, we shouldn't restrict them unnecessarily.

The solution is to use OsString and env::args_os instead of String and env::args, respectively. I'll prepare a PR :D


Edit: turns out it's harder than I expected... 😅

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions