浏览代码

Change SDT validation to take the signature

Isaac Woods 7 年之前
父节点
当前提交
f578070927
共有 2 个文件被更改,包括 6 次插入5 次删除
  1. 2 1
      src/lib.rs
  2. 4 4
      src/sdt.rs

+ 2 - 1
src/lib.rs

@@ -116,7 +116,8 @@ pub fn parse_rsdt<H>(handler            : &mut H,
     let mapping = handler.map_physical_region::<SdtHeader>(physical_address);
 
     // TODO: extend the mapping to header.length
-    // TODO: validate the signature and checksum
+    // TODO: validate the signature and checksum (XXX: if it's a RSDT, the signature will be
+    // "RSDT", whereas a XSDT will have a signature of "XSDT"
 
     if revision == 0
     {

+ 4 - 4
src/sdt.rs

@@ -20,14 +20,14 @@ pub struct SdtHeader
 impl SdtHeader
 {
     /// Check that:
-    ///     a) The signature is valid UTF8
-    ///     b) The checksum of the SDT.
+    ///     a) The signature matches the one given
+    ///     b) The checksum of the SDT
     ///
     /// This assumes that the whole SDT is mapped.
-    fn validate(&self) -> Result<(), AcpiError>
+    fn validate(&self, signature : &[u8; 4]) -> Result<(), AcpiError>
     {
         // Check the signature
-        if str::from_utf8(&self.signature).is_err()
+        if &self.signature == signature
         {
             return Err(AcpiError::SdtInvalidSignature);
         }