mirror of
https://github.com/uutils/coreutils.git
synced 2025-12-23 08:47:37 +00:00
util(cksum): Fix unexpected fail when giving --length 0 to wrong algorithm
This commit is contained in:
parent
fd83181ac2
commit
4e9d07e86c
2 changed files with 20 additions and 7 deletions
|
|
@ -383,14 +383,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
let input_length = matches.get_one::<usize>(options::LENGTH);
|
||||
|
||||
let length = match input_length {
|
||||
Some(length) => {
|
||||
if algo_name == ALGORITHM_OPTIONS_BLAKE2B {
|
||||
calculate_blake2b_length(*length)?
|
||||
} else {
|
||||
return Err(ChecksumError::LengthOnlyForBlake2b.into());
|
||||
}
|
||||
None | Some(0) => None,
|
||||
Some(length) if algo_name == ALGORITHM_OPTIONS_BLAKE2B => {
|
||||
calculate_blake2b_length(*length)?
|
||||
}
|
||||
_ => {
|
||||
return Err(ChecksumError::LengthOnlyForBlake2b.into());
|
||||
}
|
||||
None => None,
|
||||
};
|
||||
|
||||
if LEGACY_ALGORITHMS.contains(&algo_name) && check {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue