ls,dir,vdir: protect names against argv[0] (#11371)

This commit is contained in:
oech3
2026-03-18 00:37:22 +01:00
committed by GitHub
parent 6c3de3e92f
commit c6b8a81f74
5 changed files with 21 additions and 1 deletions
+1
View File
@@ -62,6 +62,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
// an uu_app function, so we return the `ls` app.
pub fn uu_app() -> Command {
uu_ls::uu_app()
.name("dir")
.override_usage(format_usage(&translate!("dir-usage")))
.about(translate!("dir-about"))
}
+1 -1
View File
@@ -1265,7 +1265,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
pub fn uu_app() -> Command {
uucore::clap_localization::configure_localized_command(
Command::new(uucore::util_name())
Command::new("ls")
.version(uucore::crate_version!())
.override_usage(format_usage(&translate!("ls-usage")))
.about(translate!("ls-about")),
+1
View File
@@ -62,6 +62,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
// an uu_app function, so we need this dummy one.
pub fn uu_app() -> Command {
uu_ls::uu_app()
.name("vdir")
.override_usage(format_usage(&translate!("vdir-usage")))
.about(translate!("vdir-about"))
}
+9
View File
@@ -74,3 +74,12 @@ fn test_help_shows_dir_not_ls() {
"Help should not show 'ls [OPTION]'"
);
}
#[test]
fn test_version() {
new_ucmd!()
.arg("--version")
.succeeds()
.no_stderr()
.stdout_is(format!("dir {}\n", uucore::crate_version!()));
}
+9
View File
@@ -74,3 +74,12 @@ fn test_help_shows_vdir_not_ls() {
"Help should not show 'ls [OPTION]'"
);
}
#[test]
fn test_version() {
new_ucmd!()
.arg("--version")
.succeeds()
.no_stderr()
.stdout_is(format!("vdir {}\n", uucore::crate_version!()));
}