Skip to content

Commit

Permalink
fix parse error when using fixed-size packet buf
Browse files Browse the repository at this point in the history
hmm, not sure when this bug was introduced... Well, it's fixed now, so
that's good.
  • Loading branch information
daniel5151 committed Sep 9, 2020
1 parent 7c67634 commit eea548b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions src/gdbstub_impl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,7 @@ impl<T: Target, C: Connection> GdbStubImpl<T, C> {
buf.push(conn.read().map_err(Error::ConnectionRead)?)?;
}

drop(buf);

let len = pkt_buf.len();
match Packet::from_buf(target, &mut pkt_buf.as_mut()[..len]) {
match Packet::from_buf(target, pkt_buf.as_mut()) {
Ok(packet) => Ok(packet),
Err(e) => {
// TODO: preserve this context within Error::PacketParse
Expand Down
2 changes: 1 addition & 1 deletion src/protocol/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl<'a> PacketBuf<'a> {
// split buffer into body and checksum components
let (body, checksum) = pkt_buf.split_at_mut(end_of_body);
let body = &mut body[1..]; // skip the '$'
let checksum = &mut checksum[1..]; // skip the '#'
let checksum = &mut checksum[1..][..2]; // skip the '#'

// validate the checksum
let checksum = decode_hex(checksum).map_err(|_| PacketParseError::MalformedChecksum)?;
Expand Down

0 comments on commit eea548b

Please sign in to comment.