From f229f28b8dd9372374138353d3cd2ba6afc4602a Mon Sep 17 00:00:00 2001 From: Sebastian Urban Date: Thu, 9 Nov 2023 21:02:31 +0100 Subject: [PATCH] Use old value for bcdVersion of OS descriptor. Older kernels only accept this old, incorrect value. Fixed kernels accept both value. --- .gitignore | 1 + src/function/custom/ffs.rs | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 4fffb2f..dfef2f1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target /Cargo.lock +.cargo/config.toml diff --git a/src/function/custom/ffs.rs b/src/function/custom/ffs.rs index 8b4162d..eef0b2c 100644 --- a/src/function/custom/ffs.rs +++ b/src/function/custom/ffs.rs @@ -331,6 +331,13 @@ impl InterfaceAssocDesc { } } +/// bcdVersion of OS descriptor. +/// +/// This should actually be 0x0100, but due to a bug in older kernels they only accept +/// 0x0001 as a valid value. Fixed kernels accepts both values. For the sake of +/// compatibility keep the old, incorrect value. +const OS_DESC_BCD_VERSION: u16 = 0x0001; + #[derive(Clone, Debug)] pub struct OsDesc { pub interface: u8, @@ -361,7 +368,7 @@ impl OsDescExt { fn write(&self, data: &mut Vec) -> Result<()> { match self { Self::ExtCompat(compats) => { - data.write_u16::(0x0100)?; // bcdVersion + data.write_u16::(OS_DESC_BCD_VERSION)?; // bcdVersion data.write_u16::(4)?; // wIndex data.write_u8(compats.len().try_into()?)?; data.write_u8(0)?; @@ -371,7 +378,7 @@ impl OsDescExt { } } Self::ExtProp(props) => { - data.write_u16::(0x0100)?; // bcdVersion + data.write_u16::(OS_DESC_BCD_VERSION)?; // bcdVersion data.write_u16::(5)?; // wIndex data.write_u16::(props.len().try_into()?)?;