Bugfix for hash generation of non utf8 files

This commit is contained in:
Daniel Heule
2026-01-09 09:54:52 +01:00
parent 95b3076fe2
commit 9bd7685dc3
4 changed files with 47 additions and 20 deletions

View File

@@ -19,7 +19,7 @@ pub mod snmp;
use bonding::bonding_status;
use config::DataFunctionsFilesum;
use filesum::filesum_filtered;
use helper::compile_re;
use helper::{compile_re, compile_re_bin};
use multipath::multipath_status;
use processes::Ptypes;
use snmp::{Oid, OidData, SnmpData};
@@ -189,10 +189,10 @@ fn t_filesum(
#[cfg(target_os = "linux")]
{
// allocate some strings for holding file contents between check runs
let mut oldpasswd = String::with_capacity(2048);
let mut oldshadow = String::with_capacity(2048);
let mut oldgroup = String::with_capacity(2048);
let mut oldauthkey = String::with_capacity(2048);
let mut oldpasswd = Vec::with_capacity(2048);
let mut oldshadow = Vec::with_capacity(2048);
let mut oldgroup = Vec::with_capacity(2048);
let mut oldauthkey = Vec::with_capacity(2048);
let mut hash_passwd = String::with_capacity(128);
let mut diff_passwd = String::with_capacity(2048);
let mut hash_shadow = String::with_capacity(128);
@@ -203,10 +203,10 @@ fn t_filesum(
let mut diff_authkey = String::with_capacity(2048);
// allocate Option<Regex> for our regex ...
let re_passwd = compile_re(options.passwd, "passwd");
let re_shadow = compile_re(options.shadow, "shadow");
let re_group = compile_re(options.group, "group");
let re_authkey = compile_re(options.authorized_keys, "authorized_keys");
let re_passwd = compile_re_bin(options.passwd, "passwd");
let re_shadow = compile_re_bin(options.shadow, "shadow");
let re_group = compile_re_bin(options.group, "group");
let re_authkey = compile_re_bin(options.authorized_keys, "authorized_keys");
// prepare variables which we use in the whole function
let oid_filesum_time = Oid::from_str("6.1.0").unwrap();