If a TXT record comes in with zero length data, we'll overflow in
the subtraction and try to allocate much too much data.
format!("{{\"type\":\"txt\",\"name\":\"{}\",\"contents\":{:?}}}", self.name.0, &self.data[..])
}
fn read_from_data(name: Name, mut data: &[u8], _wire_packet: &[u8]) -> Result<Self, ()> {
- let mut parsed_data = Vec::with_capacity(data.len() - 1);
+ let mut parsed_data = Vec::with_capacity(data.len().saturating_sub(1));
while !data.is_empty() {
let len = read_u8(&mut data)? as usize;
if data.len() < len { return Err(()); }