mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +00:00
env: prevent panic when unsetting invalid variable
This commit is contained in:
parent
db00fab7e4
commit
3d74e7b452
1 changed files with 7 additions and 0 deletions
7
src/uu/env/src/env.rs
vendored
7
src/uu/env/src/env.rs
vendored
|
@ -244,6 +244,13 @@ fn run_env(args: impl uucore::Args) -> UResult<()> {
|
|||
|
||||
// unset specified env vars
|
||||
for name in &opts.unsets {
|
||||
if name.is_empty() || name.contains(0 as char) || name.contains('=') {
|
||||
return Err(USimpleError::new(
|
||||
125,
|
||||
format!("cannot unset {}: Invalid argument", name.quote()),
|
||||
));
|
||||
}
|
||||
|
||||
env::remove_var(name);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue