Skip to content

sort --files0-from Requires UTF-8 / Panics on Non‑UTF‑8 Filenames #9696

@sylvestre

Description

@sylvestre

Component

sort

Description

When parsing NUL-separated filenames via --files0-from, uutils enforces UTF-8 and uses expect(), which causes an immediate panic when encountering valid non-UTF-8 paths; GNU treats filenames as raw bytes and does not require UTF-8 encoding.

Test / Reproduction Steps

open(b"weird\xffname", "wb").write(b"20\n10\n")
open("list0", "wb").write(b"weird\xffname\0")
$ ./target/release/coreutils sort --files0-from=list0
  • GNU: 10 20
  • uutils:
    thread 'main' (1535230) panicked at src/uu/sort/src/sort.rs:1076:18:
    Could not parse string from zero terminated input.: Utf8Error { valid_up_to: 5, error_len: Some(1) }
    note: run with RUST_BACKTRACE=1 environment variable to display a backtrac

Impact

This can cause crashes and is incompatible with GNU in terms of "allowing arbitrary byte filenames".

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions