浏览代码

Remove unnecessary length check from CAA records

Because the remaining length was calculated _based on_ the stated length, the condition would always hold.

It turns out that there are many other record types that use "the remainder of the record" to hold bytes, but at the time, CAA was the only one I knew of.
Benjamin Sago 4 年之前
父节点
当前提交
b7cc51f727
共有 1 个文件被更改,包括 1 次插入10 次删除
  1. 1 10
      dns/src/record/caa.rs

+ 1 - 10
dns/src/record/caa.rs

@@ -59,16 +59,7 @@ impl Wire for CAA {
         let value = String::from_utf8_lossy(&value_buf).to_string();
         trace!("Parsed value -> {:?}", value);
 
-        let got_length = 1 + 1 + u16::from(tag_length) + remaining_length;
-        if stated_length == got_length {
-            // This one’s a little weird, because remaining_len is based on len
-            trace!("Length is correct");
-            Ok(Self { critical, tag, value })
-        }
-        else {
-            warn!("Length is incorrect (stated length {:?}, flags plus tag plus data length {:?}", stated_length, got_length);
-            Err(WireError::WrongLabelLength { stated_length, length_after_labels: got_length })
-        }
+        Ok(Self { critical, tag, value })
     }
 }