Skip to content

Commit a175608

Browse files
wiktor-koverhacked
andcommitted
Fix Unparsed::encoded_len implementation
`Unparsed` contains raw bytes and as such the length is already stored inside and doesn't require any additional wrapping. Additionally fix the `Extension::encoded_len` implementation to use `Unparsed::encoded_len` instead of directly accessing the `Vec`. Co-authored-by: Ross Williams <ross@ross-williams.net> Fixes: #64 Signed-off-by: Wiktor Kwapisiewicz <wiktor@metacode.biz>
1 parent 6b369db commit a175608

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/proto/message.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ impl Decode for Extension {
617617

618618
impl Encode for Extension {
619619
fn encoded_len(&self) -> ssh_encoding::Result<usize> {
620-
[self.name.encoded_len()?, self.details.0.encoded_len()?].checked_sum()
620+
[self.name.encoded_len()?, self.details.encoded_len()?].checked_sum()
621621
}
622622

623623
fn encode(&self, writer: &mut impl Writer) -> ssh_encoding::Result<()> {
@@ -653,7 +653,7 @@ impl From<Vec<u8>> for Unparsed {
653653

654654
impl Encode for Unparsed {
655655
fn encoded_len(&self) -> ssh_encoding::Result<usize> {
656-
self.0.encoded_len()
656+
Ok(self.0.len())
657657
}
658658

659659
fn encode(&self, writer: &mut impl Writer) -> ssh_encoding::Result<()> {

0 commit comments

Comments
 (0)