nsh icon indicating copy to clipboard operation
nsh copied to clipboard

Crash on binary strings

Open xzfc opened this issue 3 years ago • 1 comments

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.

xzfc avatar Oct 23 '21 15:10 xzfc

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

nuta avatar Oct 24 '21 12:10 nuta