mirror of https://github.com/ctz/rustls
Assert x.509 name is shorter than 64KB
Otherwise this function produces incorrect output.
This commit is contained in:
parent
22a9a49bd4
commit
227d9a2aff
|
@ -14,6 +14,8 @@ fn wrap_in_asn1_len(bytes: &mut Vec<u8>) {
|
|||
bytes.insert(0, 0x82u8);
|
||||
bytes.insert(1, ((len >> 8) & 0xff) as u8);
|
||||
bytes.insert(2, (len & 0xff) as u8);
|
||||
} else {
|
||||
assert!(len <= 0xffff, "excessively long x.509 name");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,3 +62,13 @@ fn test_large() {
|
|||
assert_eq!(vec![0x30, 0x82, 0x12, 0x34, 0x12, 0x12],
|
||||
val[..6].to_vec());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_huge() {
|
||||
let mut val = Vec::new();
|
||||
val.resize(0xffff, 0x12);
|
||||
wrap_in_sequence(&mut val);
|
||||
assert_eq!(vec![0x30, 0x82, 0xff, 0xff, 0x12, 0x12],
|
||||
val[..6].to_vec());
|
||||
assert_eq!(val.len(), 0xffff + 4);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue