fix(writer): serialize complete records with correctly sized buffers
Include record headers in wire lengths, allocate initialized array and padded string buffers, and handle empty strings. Write all bytes to short writers and reject oversized records before writing.
This commit is contained in:
parent
aa2132dc6e
commit
3783320f82
1 changed files with 106 additions and 15 deletions
|
|
@ -98,8 +98,7 @@ pub fn parse_bitarray(input: &[u8]) -> IResult<'_, [bool; 16]> {
|
|||
pub fn parse_ascii(input: &[u8], length: u16) -> IResult<'_, Vec<u8>> {
|
||||
let length = length as usize;
|
||||
let (input, data) = take_bytes(input, length)?;
|
||||
let last = data[length - 1];
|
||||
let true_length = if last == 0 { length - 1 } else { length };
|
||||
let true_length = length - usize::from(data.last() == Some(&0));
|
||||
let vec = data[..true_length].to_vec();
|
||||
Ok((input, vec))
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue