mirror of
https://github.com/NLnetLabs/domain.git
synced 2026-09-29 05:04:58 +02:00
Permit zone file strings upto AND including 255 characters in length. (#284)
This PR fixes a bug in the inplace zone parser that rejects character string of length 255.
This commit is contained in:
+15
-2
@@ -913,7 +913,7 @@ impl<'a> EntryScanner<'a> {
|
||||
// or an escape sequence.
|
||||
while self.zonefile.buf.next_ascii_symbol()?.is_some() {
|
||||
*write += 1;
|
||||
if *write >= latest {
|
||||
if *write > latest {
|
||||
return Err(EntryError::bad_charstr());
|
||||
}
|
||||
}
|
||||
@@ -930,7 +930,7 @@ impl<'a> EntryScanner<'a> {
|
||||
Some(sym) => {
|
||||
self.zonefile.buf.buf[*write] = sym.into_octet()?;
|
||||
*write += 1;
|
||||
if *write >= latest {
|
||||
if *write > latest {
|
||||
return Err(EntryError::bad_charstr());
|
||||
}
|
||||
}
|
||||
@@ -1638,4 +1638,17 @@ mod test {
|
||||
"../../test-data/zonefiles/unknown.yaml"
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_chrstr_decoding() {
|
||||
TestCase::test(include_str!("../../test-data/zonefiles/strlen.yaml"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic(expected = "character string with more than 255 octets")]
|
||||
fn test_chrstr_overlfow_decoding() {
|
||||
TestCase::test(include_str!(
|
||||
"../../test-data/zonefiles/stroverflow.yaml"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
origin: example.com.
|
||||
zonefile: |
|
||||
254.short 3600 IN TXT "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234"
|
||||
255.max 3600 IN TXT "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345"
|
||||
result:
|
||||
- owner: 254.short.example.com.
|
||||
class: IN
|
||||
ttl: 3600
|
||||
data: !Txt
|
||||
- 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234
|
||||
- owner: 255.max.example.com.
|
||||
class: IN
|
||||
ttl: 3600
|
||||
data: !Txt
|
||||
- 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345
|
||||
@@ -0,0 +1,9 @@
|
||||
origin: example.com.
|
||||
zonefile: |
|
||||
256.long 3600 IN TXT "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456"
|
||||
result:
|
||||
- owner: 256.long.example.com.
|
||||
class: IN
|
||||
ttl: 3600
|
||||
data: !Txt
|
||||
- 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456
|
||||
Reference in New Issue
Block a user