Skip to content

Commit

Permalink
rtu: Fix unbounded memory allocations by wrong reserve() usage
Browse files Browse the repository at this point in the history
  • Loading branch information
uklotzde committed Nov 29, 2024
1 parent 8a886c8 commit f4f6216
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/codec/rtu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ impl<'a> Encoder<RequestAdu<'a>> for ClientCodec {
} = adu;
let buf_offset = buf.len();
let request_pdu_size = request_pdu_size(&request)?;
buf.reserve((buf.capacity() - buf_offset) + request_pdu_size + 3);
buf.reserve(request_pdu_size + 3);
buf.put_u8(hdr.slave_id);
encode_request_pdu(buf, &request);
let crc = calc_crc(&buf[buf_offset..]);
Expand Down

0 comments on commit f4f6216

Please sign in to comment.