Skip to content

Commit

Permalink
Use old value for bcdVersion of OS descriptor.
Browse files Browse the repository at this point in the history
Older kernels only accept this old, incorrect value.
Fixed kernels accept both value.
  • Loading branch information
surban committed Nov 9, 2023
1 parent 46fb08b commit f229f28
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
/Cargo.lock
.cargo/config.toml
11 changes: 9 additions & 2 deletions src/function/custom/ffs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -361,7 +368,7 @@ impl OsDescExt {
fn write(&self, data: &mut Vec<u8>) -> Result<()> {
match self {
Self::ExtCompat(compats) => {
data.write_u16::<LE>(0x0100)?; // bcdVersion
data.write_u16::<LE>(OS_DESC_BCD_VERSION)?; // bcdVersion
data.write_u16::<LE>(4)?; // wIndex
data.write_u8(compats.len().try_into()?)?;
data.write_u8(0)?;
Expand All @@ -371,7 +378,7 @@ impl OsDescExt {
}
}
Self::ExtProp(props) => {
data.write_u16::<LE>(0x0100)?; // bcdVersion
data.write_u16::<LE>(OS_DESC_BCD_VERSION)?; // bcdVersion
data.write_u16::<LE>(5)?; // wIndex
data.write_u16::<LE>(props.len().try_into()?)?;

Expand Down

0 comments on commit f229f28

Please sign in to comment.