cksum -c /dev/null 2>/dev/full should not abort (#10643)

This commit is contained in:
oech3
2026-02-01 21:44:17 +01:00
committed by GitHub
parent 26498f5b8b
commit 2a8811d92c
@@ -5,10 +5,12 @@
// spell-checker:ignore rsplit hexdigit bitlen invalidchecksum inva idchecksum xffname
use crate::util_name;
use std::ffi::OsStr;
use std::fmt::Display;
use std::fs::File;
use std::io::{self, BufReader, Read, Write, stdin};
use std::io::{self, BufReader, Read, Write, stderr, stdin};
use os_display::Quotable;
@@ -17,8 +19,7 @@ use crate::error::{FromIo, UError, UResult, USimpleError};
use crate::quoting_style::{QuotingStyle, locale_aware_escape_name};
use crate::sum::DigestOutput;
use crate::{
os_str_as_bytes, os_str_from_bytes, read_os_string_lines, show, show_error, show_warning_caps,
translate,
os_str_as_bytes, os_str_from_bytes, read_os_string_lines, show, show_warning_caps, translate,
};
/// To what level should checksum validation print logging info.
@@ -173,8 +174,10 @@ fn print_cksum_report(res: &ChecksumResult) {
/// Print a "no properly formatted lines" message in stderr
#[inline]
fn log_no_properly_formatted(filename: impl Display) {
show_error!(
"{}",
let _ = writeln!(
stderr(),
"{}: {}",
util_name(),
translate!("checksum-no-properly-formatted", "checksum_file" => filename)
);
}
@@ -182,8 +185,10 @@ fn log_no_properly_formatted(filename: impl Display) {
/// Print a "no file was verified" message in stderr
#[inline]
fn log_no_file_verified(filename: impl Display) {
show_error!(
"{}",
let _ = writeln!(
stderr(),
"{}: {}",
util_name(),
translate!("checksum-no-file-verified", "checksum_file" => filename)
);
}
@@ -839,7 +844,7 @@ fn process_checksum_file(
Ok(f) => f,
Err(e) => {
// Could not read the file, show the error and continue to the next file
show_error!("{e}");
let _ = writeln!(stderr(), "{}: {e}", util_name());
return Err(FileCheckError::CantOpenChecksumFile);
}
}
@@ -891,8 +896,10 @@ fn process_checksum_file(
} else {
"Unknown algorithm"
};
show_error!(
"{}",
let _ = writeln!(
stderr(),
"{}: {}",
util_name(),
translate!("checksum-error-algo-bad-format", "file" => filename_input.maybe_quote(), "line" => i + 1, "algo" => algo)
);
}