mirror of
https://github.com/ZeusWPI/ZNS.git
synced 2024-11-22 05:41:11 +01:00
Add size restrictions
This commit is contained in:
parent
7b5fad0306
commit
271ee5e395
3 changed files with 20 additions and 1 deletions
|
@ -239,7 +239,6 @@ impl KeyTransformer for OpenSSHKey {
|
||||||
}?;
|
}?;
|
||||||
|
|
||||||
let length = reader.read_u32()?;
|
let length = reader.read_u32()?;
|
||||||
println!("{}", length);
|
|
||||||
reader.read(length as usize)?;
|
reader.read(length as usize)?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::fmt::format;
|
||||||
|
|
||||||
use diesel::prelude::*;
|
use diesel::prelude::*;
|
||||||
use diesel::sql_types::Text;
|
use diesel::sql_types::Text;
|
||||||
use zns::{
|
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> {
|
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 {
|
let record = Record {
|
||||||
name: rr.name.join("."),
|
name: rr.name.join("."),
|
||||||
_type: rr._type.clone().into(),
|
_type: rr._type.clone().into(),
|
||||||
|
|
|
@ -131,6 +131,13 @@ impl FromBytes for LabelString {
|
||||||
})?,
|
})?,
|
||||||
);
|
);
|
||||||
code = reader.read_u8()?;
|
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 {
|
if code & 0b11000000 != 0 {
|
||||||
|
|
Loading…
Reference in a new issue