Skip to content

Commit

Permalink
rtu: Fix unbounded memory allocations by wrong reserve() usage (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
uklotzde authored Dec 1, 2024
1 parent 9cc04b2 commit 63de3be
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 63de3be

Please # to comment.