10000 env: cannot handle empty-string envvar · Issue #6175 · uutils/coreutils · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

env: cannot handle empty-string envvar #6175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
BenWiederhake opened this issue Apr 1, 2024 · 2 comments · Fixed by #7956
Closed

env: cannot handle empty-string envvar #6175

BenWiederhake opened this issue Apr 1, 2024 · 2 comments · Fixed by #7956
Labels

Comments

@BenWiederhake
Copy link
Collaborator

The empty string is apparently a valid name for an environment variable, even though I strongly expect that it is used only for malicious purposes:

$ env =a env | grep -Fv PATH # GNU with GNU
PWD=/home/nattiff/Bilder/xperia/Kamera
LS_COLORS=
SHLVL=1
PATH=/bin:/usr/local/bin:/usr/bin:/bin
_=/bin/env
=a
$ ./target/debug/coreutils env =a env | grep -Fv PATH # uutils calling GNU
env: warning: no name specified for value 'a'
PWD=/home/nattiff/workspace/coreutils-rs
LS_COLORS=
SHLVL=1
_=./target/debug/coreutils
$ env =a foo=x ./target/debug/coreutils env | grep -Fv PATH # GNU calling uutils, demonstrating that the envvar was dropped, not skipped
PWD=/home/nattiff/workspace/coreutils-rs
LS_COLORS=
SHLVL=1
_=/bin/env
foo=x
$ env =a ./target/debug/coreutils env | grep -Fv PATH # GNU calling uutils
PWD=/home/nattiff/workspace/coreutils-rs
LS_COLORS=
SHLVL=1
_=/bin/env
$ ./target/debug/coreutils env =a ./target/debug/coreutils env | grep -Fv PATH # uutils calling uutils
env: warning: no name specified for value 'a'
PWD=/home/nattiff/workspace/coreutils-rs
LS_COLORS=
SHLVL=1
_=./target/debug/coreutils

This means two issues:

  • uutils does not set the envvar, and instead writes something to stderr
  • uutils does not parse the envvar, and instead skips it

Found while reviewing #6167.

BenWiederhake added a commit to BenWiederhake/coreutils-rs that referenced this issue Apr 1, 2024
Inspired by uutils#6167, uutils#6175, and the observation that 'echo hello "" world | hd' outputs extra spaces.
@Qelxiros
Copy link
Contributor

Should this be closed? Rust's env::set_var function explicitly doesn't support this, and I agree with your assessment that it's probably always malicious.

@BenWiederhake
Copy link
Collaborator Author

I would strongly prefer if someone writes a testcase, and documents this divergence from GNU in docs/src/extensions.md. That someone could be you, someone else, or it could end up being me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0