baseNM: protect names against argv[0] (#11373)

This commit is contained in:
oech3
2026-03-18 08:36:30 +09:00
committed by GitHub
parent 9beb03885f
commit 6c3de3e92f
7 changed files with 32 additions and 4 deletions
+1 -1
View File
@@ -16,5 +16,5 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
}
pub fn uu_app() -> Command {
base_common::base_app(translate!("base32-about"), translate!("base32-usage"))
base_common::base_app(translate!("base32-about"), translate!("base32-usage")).name("base32")
}
+1 -1
View File
@@ -104,7 +104,7 @@ pub fn parse_base_cmd_args(args: impl uucore::Args, command: Command) -> UResult
}
pub fn base_app(about: String, usage: String) -> Command {
let cmd = Command::new(uucore::util_name())
let cmd = Command::new("")
.version(uucore::crate_version!())
.about(about)
.override_usage(format_usage(&usage))
+1 -1
View File
@@ -16,5 +16,5 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
}
pub fn uu_app() -> Command {
base_common::base_app(translate!("base64-about"), translate!("base64-usage"))
base_common::base_app(translate!("base64-about"), translate!("base64-usage")).name("base64")
}
+2 -1
View File
@@ -45,7 +45,8 @@ fn get_encodings() -> Vec<(&'static str, Format, String)> {
pub fn uu_app() -> Command {
let encodings = get_encodings();
let mut command = base_common::base_app(translate!("basenc-about"), translate!("basenc-usage"));
let mut command = base_common::base_app(translate!("basenc-about"), translate!("basenc-usage"))
.name("basenc");
for encoding in &encodings {
let raw_arg = Arg::new(encoding.0)
+9
View File
@@ -6,6 +6,15 @@
use uutests::new_ucmd;
#[test]
fn test_version() {
new_ucmd!()
.arg("--version")
.succeeds()
.no_stderr()
.stdout_is(format!("base32 {}\n", uucore::crate_version!()));
}
#[test]
fn test_encode() {
let input = "Hello, World!";
+9
View File
@@ -9,6 +9,15 @@
use uutests::at_and_ucmd;
use uutests::new_ucmd;
#[test]
fn test_version() {
new_ucmd!()
.arg("--version")
.succeeds()
.no_stderr()
.stdout_is(format!("base64 {}\n", uucore::crate_version!()));
}
#[test]
#[cfg(target_os = "linux")]
fn test_base64_non_utf8_paths() {
+9
View File
@@ -8,6 +8,15 @@
use uutests::{at_and_ucmd, new_ucmd};
#[test]
fn test_version() {
new_ucmd!()
.arg("--version")
.succeeds()
.no_stderr()
.stdout_is(format!("basenc {}\n", uucore::crate_version!()));
}
#[test]
fn test_z85_not_padded_decode() {
// The z85 crate deviates from the standard in some cases; we have to catch those