Skip to content

Commit 57f69ad

Browse files
authored
*sum: protect names against argv[0] (#11375)
1 parent e37c158 commit 57f69ad

4 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/uu/b2sum/src/b2sum.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
2626
#[inline]
2727
pub fn uu_app() -> Command {
2828
standalone_checksum_app_with_length(translate!("b2sum-about"), translate!("b2sum-usage"))
29+
.name("b2sum")
2930
}

src/uu/checksum_common/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ macro_rules! declare_standalone {
4848
::uucore::translate!(concat!($bin, "-about")),
4949
::uucore::translate!(concat!($bin, "-usage")),
5050
)
51+
.name($bin)
5152
}
5253
};
5354
}
@@ -96,7 +97,7 @@ pub fn standalone_main(algo: AlgoKind, cmd: Command, args: impl uucore::Args) ->
9697

9798
/// Base command processing for all the checksum executables.
9899
pub fn default_checksum_app(about: String, usage: String) -> Command {
99-
Command::new(util_name())
100+
Command::new("")
100101
.version(crate_version!())
101102
.help_template(localized_help_template(util_name()))
102103
.about(about)

src/uu/cksum/src/cksum.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
118118

119119
pub fn uu_app() -> Command {
120120
default_checksum_app(translate!("cksum-about"), translate!("cksum-usage"))
121+
.name("cksum")
121122
.with_algo()
122123
.with_untagged()
123124
.with_tag(true)

src/uu/sum/src/sum.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
137137
}
138138

139139
pub fn uu_app() -> Command {
140-
Command::new(uucore::util_name())
140+
Command::new("sum")
141141
.version(uucore::crate_version!())
142-
.help_template(uucore::localized_help_template(uucore::util_name()))
142+
.help_template(uucore::localized_help_template("sum"))
143143
.override_usage(format_usage(&translate!("sum-usage")))
144144
.about(translate!("sum-about"))
145145
.infer_long_args(true)

0 commit comments

Comments
 (0)