Skip to content

Commit

Permalink
IGP handle crypto padding
Browse files Browse the repository at this point in the history
  • Loading branch information
alpinskiy committed Jan 14, 2025
1 parent f5837f0 commit 433f996
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions internal/vkgo/rpc/statshouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,16 +221,18 @@ func forwardPacketBody(dst, src *PacketConn, header *packetHeader, buf []byte) (
return res
}
// skip padding
if n := int(-header.length & 3); n != 0 {
if _, err := io.ReadFull(src.r, src.headerReadBuf[:n]); err != nil {
res.ReadErr = err
return res
}
for i := 0; i < n; i++ {
if src.headerReadBuf[i] != 0 {
res.ReadErr = errNonZeroPadding
if src.w.isEncrypted() {
if n := int(-header.length & 3); n != 0 {
if _, err := io.ReadFull(src.r, src.headerReadBuf[:n]); err != nil {
res.ReadErr = err
return res
}
for i := 0; i < n; i++ {
if src.headerReadBuf[i] != 0 {
res.ReadErr = errNonZeroPadding
return res
}
}
}
}
return res
Expand Down

0 comments on commit 433f996

Please sign in to comment.