mirror of
https://github.com/ZeusWPI/ZNS.git
synced 2024-10-30 05:24:26 +01:00
fix wrong condition check
This commit is contained in:
parent
c213ac14f9
commit
cb4812a5c5
1 changed files with 27 additions and 41 deletions
|
@ -158,12 +158,6 @@ impl ToBytes for LabelString {
|
||||||
impl FromBytes for Question {
|
impl FromBytes for Question {
|
||||||
fn from_bytes(reader: &mut Reader) -> Result<Self> {
|
fn from_bytes(reader: &mut Reader) -> Result<Self> {
|
||||||
// 16 for length octet + zero length octet
|
// 16 for length octet + zero length octet
|
||||||
if reader.unread_bytes() < 2 + size_of::<Class>() + size_of::<Type>() {
|
|
||||||
Err(ZNSError::Parse {
|
|
||||||
object: String::from("Question"),
|
|
||||||
message: String::from("len of bytes smaller then minimum size"),
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
let qname = LabelString::from_bytes(reader)?;
|
let qname = LabelString::from_bytes(reader)?;
|
||||||
|
|
||||||
if reader.unread_bytes() < 4 {
|
if reader.unread_bytes() < 4 {
|
||||||
|
@ -186,7 +180,6 @@ impl FromBytes for Question {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl ToBytes for Question {
|
impl ToBytes for Question {
|
||||||
fn to_bytes(question: Self) -> Vec<u8> {
|
fn to_bytes(question: Self) -> Vec<u8> {
|
||||||
|
@ -200,12 +193,6 @@ impl ToBytes for Question {
|
||||||
impl FromBytes for RR {
|
impl FromBytes for RR {
|
||||||
fn from_bytes(reader: &mut Reader) -> Result<Self> {
|
fn from_bytes(reader: &mut Reader) -> Result<Self> {
|
||||||
let name = LabelString::from_bytes(reader)?;
|
let name = LabelString::from_bytes(reader)?;
|
||||||
if reader.unread_bytes() < size_of::<Type>() + size_of::<Class>() + 6 {
|
|
||||||
Err(ZNSError::Parse {
|
|
||||||
object: String::from("RR"),
|
|
||||||
message: String::from("len of rest of bytes smaller then minimum size"),
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
let _type = Type::from(reader.read_u16()?);
|
let _type = Type::from(reader.read_u16()?);
|
||||||
let class = Class::from(reader.read_u16()?);
|
let class = Class::from(reader.read_u16()?);
|
||||||
let ttl = reader.read_i32()?;
|
let ttl = reader.read_i32()?;
|
||||||
|
@ -227,7 +214,6 @@ impl FromBytes for RR {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl ToBytes for RR {
|
impl ToBytes for RR {
|
||||||
fn to_bytes(rr: Self) -> Vec<u8> {
|
fn to_bytes(rr: Self) -> Vec<u8> {
|
||||||
|
|
Loading…
Reference in a new issue