From 09f567e04cb50bcf029a27dda61cba5b70a7955c Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Fri, 21 Aug 2026 16:28:43 -0700 Subject: [PATCH 1/4] Fix clippy rule violation --- lib/dsc-lib/src/functions/int.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/dsc-lib/src/functions/int.rs b/lib/dsc-lib/src/functions/int.rs index 5297e3aae..c4f81bc25 100644 --- a/lib/dsc-lib/src/functions/int.rs +++ b/lib/dsc-lib/src/functions/int.rs @@ -30,16 +30,15 @@ impl Function for Int { fn invoke(&self, args: &[Value], _context: &Context) -> Result { let arg = &args[0]; - let value: i64; - if arg.is_string() { + let value: i64 = if arg.is_string() { let input = arg.as_str().ok_or(DscError::FunctionArg("int".to_string(), t!("functions.int.invalidInput").to_string()))?; let result = input.parse::().map_err(|_| DscError::FunctionArg("int".to_string(), t!("functions.int.parseStringError").to_string()))?; - value = NumCast::from(result).ok_or(DscError::FunctionArg("int".to_string(), t!("functions.int.castError").to_string()))?; + NumCast::from(result).ok_or(DscError::FunctionArg("int".to_string(), t!("functions.int.castError").to_string()))? } else if arg.is_number() { - value = arg.as_i64().ok_or(DscError::FunctionArg("int".to_string(), t!("functions.int.parseNumError").to_string()))?; + arg.as_i64().ok_or(DscError::FunctionArg("int".to_string(), t!("functions.int.parseNumError").to_string()))? } else { return Err(DscError::FunctionArg("int".to_string(), t!("functions.invalidArgType").to_string())); - } + }; Ok(Value::Number(value.into())) } } From 183a6669ab6dfc884bd400ecedbc24ab873a88cf Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL HE/HIM) (from Dev Box)" Date: Fri, 21 Aug 2026 18:15:30 -0700 Subject: [PATCH 2/4] fix build on Windows --- helpers.build.psm1 | 6 +++--- lib/dsc-lib-registry/src/lib.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/helpers.build.psm1 b/helpers.build.psm1 index c129322ce..0e8f589d4 100644 --- a/helpers.build.psm1 +++ b/helpers.build.psm1 @@ -388,9 +388,9 @@ function Get-RustUp { Write-Verbose -Verbose "Using msrustup" $rustup = 'msrustup' $channel = 'ms-prod-1.95' - if ($architecture -eq 'current') { - $env:MSRUSTUP_TOOLCHAIN = "$architecture" - } + # if ($architecture -ne 'current') { + # $env:MSRUSTUP_TOOLCHAIN = "$architecture" + # } } elseif ($null -ne (Get-Command rustup -CommandType Application -ErrorAction Ignore)) { $rustup = 'rustup' $env:TESTING_FUNCTION_ENV = "lolwhat" diff --git a/lib/dsc-lib-registry/src/lib.rs b/lib/dsc-lib-registry/src/lib.rs index 3cd677c72..efcab8aff 100644 --- a/lib/dsc-lib-registry/src/lib.rs +++ b/lib/dsc-lib-registry/src/lib.rs @@ -745,7 +745,7 @@ fn convert_value_data_to_offline(value_data: &RegistryValueData) -> Result<(u32, /// Decode a null-terminated UTF-16LE byte slice to a String. fn decode_utf16_bytes(data: &[u8]) -> String { - let u16_slice: Vec = data.chunks_exact(2) + let u16_slice: Vec = data.as_chunks::<2>().0.iter() .map(|chunk| u16::from_le_bytes([chunk[0], chunk[1]])) .collect(); // Strip trailing null @@ -761,7 +761,7 @@ fn encode_utf16_bytes(s: &str) -> Vec { /// Decode REG_MULTI_SZ: double-null-terminated list of null-terminated UTF-16LE strings. fn decode_multi_sz(data: &[u8]) -> Vec { - let u16_slice: Vec = data.chunks_exact(2) + let u16_slice: Vec = data.as_chunks::<2>().0.iter() .map(|chunk| u16::from_le_bytes([chunk[0], chunk[1]])) .collect(); let mut strings = Vec::new(); From b3e00cd5324e8d50ded4d34bb53a7ab04a081fb7 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL HE/HIM) (from Dev Box)" Date: Fri, 21 Aug 2026 19:56:13 -0700 Subject: [PATCH 3/4] Add registry decoder test coverage Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- lib/dsc-lib-registry/src/lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/dsc-lib-registry/src/lib.rs b/lib/dsc-lib-registry/src/lib.rs index efcab8aff..ff786271b 100644 --- a/lib/dsc-lib-registry/src/lib.rs +++ b/lib/dsc-lib-registry/src/lib.rs @@ -789,6 +789,17 @@ fn encode_multi_sz(strings: &[String]) -> Vec { result.iter().flat_map(|&c| c.to_le_bytes()).collect() } +#[test] +fn decode_utf16_bytes_ignores_incomplete_code_unit() { + assert_eq!(decode_utf16_bytes(&[b'A', 0, 0xff]), "A"); +} + +#[test] +fn decode_multi_sz_ignores_incomplete_code_unit() { + let data = [b'A', 0, 0, 0, 0, 0, 0xff]; + assert_eq!(decode_multi_sz(&data), vec!["A"]); +} + #[test] fn get_hklm_key() { let reg_helper = RegistryHelper::new_from_json(r#"{"keyPath":"HKEY_LOCAL_MACHINE"}"#).unwrap(); From 9038510d3abdea8eff6a794439d69ae665bb1d46 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL HE/HIM) (from Dev Box)" Date: Fri, 21 Aug 2026 21:35:35 -0700 Subject: [PATCH 4/4] remove incorrect msrustup env var --- helpers.build.psm1 | 3 --- 1 file changed, 3 deletions(-) diff --git a/helpers.build.psm1 b/helpers.build.psm1 index 0e8f589d4..23f16aab4 100644 --- a/helpers.build.psm1 +++ b/helpers.build.psm1 @@ -388,9 +388,6 @@ function Get-RustUp { Write-Verbose -Verbose "Using msrustup" $rustup = 'msrustup' $channel = 'ms-prod-1.95' - # if ($architecture -ne 'current') { - # $env:MSRUSTUP_TOOLCHAIN = "$architecture" - # } } elseif ($null -ne (Get-Command rustup -CommandType Application -ErrorAction Ignore)) { $rustup = 'rustup' $env:TESTING_FUNCTION_ENV = "lolwhat"