Skip to content

Commit 97d2b1e

Browse files
authored
Merge branch 'main' into locales-n
2 parents f46e737 + 8f6e720 commit 97d2b1e

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

.github/workflows/CICD.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ jobs:
290290
mv -T target target.cache
291291
fi
292292
# Check that we don't cross-build uudoc
293+
# also do not try to generate manpages for part of hashsum
293294
make install-manpages PREFIX=/tmp/usr UTILS=true RUSTC_ARCH="--target aarch64-unknown-linux-gnu"
294295
# build (host)
295296
make build

GNUmakefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ ifneq ($(OS),Windows_NT)
230230
endif
231231

232232
UTILS ?= $(filter-out $(SKIP_UTILS),$(PROGS))
233+
ifneq ($(filter hashsum,$(UTILS)),hashsum)
234+
HASHSUM_PROGS :=
235+
endif
233236

234237
ifneq ($(findstring stdbuf,$(UTILS)),)
235238
# Use external libstdbuf per default. It is more robust than embedding libstdbuf.

src/uu/cksum/src/cksum.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -383,14 +383,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
383383
let input_length = matches.get_one::<usize>(options::LENGTH);
384384

385385
let length = match input_length {
386-
Some(length) => {
387-
if algo_name == ALGORITHM_OPTIONS_BLAKE2B {
388-
calculate_blake2b_length(*length)?
389-
} else {
390-
return Err(ChecksumError::LengthOnlyForBlake2b.into());
391-
}
386+
None | Some(0) => None,
387+
Some(length) if algo_name == ALGORITHM_OPTIONS_BLAKE2B => {
388+
calculate_blake2b_length(*length)?
389+
}
390+
_ => {
391+
return Err(ChecksumError::LengthOnlyForBlake2b.into());
392392
}
393-
None => None,
394393
};
395394

396395
if LEGACY_ALGORITHMS.contains(&algo_name) && check {

tests/by-util/test_cksum.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,20 @@ fn test_length_with_wrong_algorithm() {
348348
.stderr_contains("cksum: --length is only supported with --algorithm=blake2b");
349349
}
350350

351+
/// Giving --length to a wrong algorithm doesn't fail if the length is zero
352+
#[test]
353+
fn test_length_is_zero_with_wrong_algorithm() {
354+
for algo in ["md5", "crc", "sha1", "sha224", "sha256", "sha384", "sha512"] {
355+
new_ucmd!()
356+
.arg("--length=0")
357+
.args(&["-a", algo])
358+
.arg("lorem_ipsum.txt")
359+
.succeeds()
360+
.no_stderr()
361+
.stdout_is_fixture(format!("{algo}_single_file.expected"));
362+
}
363+
}
364+
351365
#[test]
352366
fn test_length_not_supported() {
353367
new_ucmd!()

0 commit comments

Comments
 (0)