10
0
Fork 0
mirror of https://github.com/ZeusWPI/ZNS.git synced 2024-11-21 21:41:10 +01:00

Add size restrictions

This commit is contained in:
Xander Bil 2024-08-17 19:26:16 +02:00
parent 7b5fad0306
commit 271ee5e395
No known key found for this signature in database
GPG key ID: EC9706B54A278598
3 changed files with 20 additions and 1 deletions

View file

@ -239,7 +239,6 @@ impl KeyTransformer for OpenSSHKey {
}?;
let length = reader.read_u32()?;
println!("{}", length);
reader.read(length as usize)?;
Ok(Self {

View file

@ -1,3 +1,5 @@
use std::fmt::format;
use diesel::prelude::*;
use diesel::sql_types::Text;
use zns::{
@ -90,7 +92,18 @@ impl Record {
}
}
const MAX_RDATA_SIZE: usize = 1000;
pub fn insert_into_database(rr: &RR, connection: &mut PgConnection) -> Result<(), ZNSError> {
if rr.rdata.len() > MAX_RDATA_SIZE {
return Err(ZNSError::Refused {
message: format!(
"RDATA size of record is bigger then maximum limit: {}",
MAX_RDATA_SIZE
),
});
}
let record = Record {
name: rr.name.join("."),
_type: rr._type.clone().into(),

View file

@ -131,6 +131,13 @@ impl FromBytes for LabelString {
})?,
);
code = reader.read_u8()?;
// Set maximum number of labels.
if out.len() > 255 {
return Err(ZNSError::Refused {
message: String::from("Exceeded maximum number of labels"),
});
}
}
if code & 0b11000000 != 0 {