mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-22 07:32:32 +01:00
refactor(byteframe): replace read-overflow panic with sticky error
ByteFrame previously panicked on out-of-bounds reads, which crashed
the server when parsing malformed client packets. Now sets a sticky
error (checked via Err()) and returns zero values, matching the
encoding/binary scanner pattern. The session recv loop checks Err()
after parsing to reject malformed packets gracefully.
Also replaces remaining panic("Not implemented") stubs in network
packet Build/Parse methods with proper error returns.
This commit is contained in:
@@ -256,6 +256,14 @@ func (s *Session) handlePacketGroup(pktGroup []byte) {
|
||||
)
|
||||
return
|
||||
}
|
||||
if bf.Err() != nil {
|
||||
s.logger.Warn("Malformed packet (read overflow during parse)",
|
||||
zap.String("name", s.Name),
|
||||
zap.Stringer("opcode", opcode),
|
||||
zap.Error(bf.Err()),
|
||||
)
|
||||
return
|
||||
}
|
||||
// Handle the packet.
|
||||
handler, ok := s.server.handlerTable[opcode]
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user