nuta / nsh

A command-line shell like fish, but POSIX compatible.
906 stars 34 forks source link

Crash on binary strings #14

Open xzfc opened 2 years ago

xzfc commented 2 years ago

The following snippets crash nsh:

  1. Invalid UTF-8 in the command substitution output: $(printf '\xff').
  2. Invalid UTF-8 in env vars: (run from bash) A=$'\xff' ./target/release/nsh.
  3. Null byte in command arguments: true $(printf '\x00').

Possible fix to 1 and 2: store strings in Vec<u8>, OsString, or bstr rather than String which forces strings to be valid UTF-8.

Proper behavior for 3 is not specified for POSIX sh; other shells treat it differently.

nuta commented 2 years ago

Good catch and thanks for detailed explanation! I'll work on it when I have time :)