mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
env: prevent panic when unsetting invalid variable
This commit is contained in:
Vendored
+7
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user