1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-12 04:43:22 +08:00

fix(recv): panic on short data len

This commit is contained in:
源文雨
2025-02-21 21:44:39 +09:00
parent fae1b768f2
commit 552be0335b
4 changed files with 24 additions and 1 deletions

View File

@@ -130,6 +130,12 @@ func (m *Me) listen() (conn p2p.Conn, err error) {
}
continue
}
if n <= 0 {
if config.ShowDebugLog {
logrus.Debugln("[listen] unexpected read n =", n)
}
continue
}
lq := lstnq{
index: -1,
addr: addr,

View File

@@ -32,8 +32,19 @@ func (m *Me) wait(data []byte) *head.Packet {
}
if m.base14 {
data = base14.Decode(data)
if len(data) < bound {
bound = len(data)
endl = "."
}
if config.ShowDebugLog {
logrus.Debugln("[recv] data b14ed", hex.EncodeToString(data[:bound]), endl)
}
}
seq, data := m.xordec(data)
if len(data) < bound {
bound = len(data)
endl = "."
}
if config.ShowDebugLog {
logrus.Debugln("[recv] data xored", hex.EncodeToString(data[:bound]), endl)
}