mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-21 23:22:34 +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:
@@ -1,6 +1,8 @@
|
||||
package binpacket
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"erupe-ce/common/byteframe"
|
||||
"erupe-ce/common/stringsupport"
|
||||
"erupe-ce/network"
|
||||
@@ -13,7 +15,7 @@ type MsgBinMailNotify struct {
|
||||
|
||||
// Parse parses the packet from binary.
|
||||
func (m MsgBinMailNotify) Parse(bf *byteframe.ByteFrame) error {
|
||||
panic("implement me")
|
||||
return fmt.Errorf("MsgBinMailNotify.Parse: not implemented")
|
||||
}
|
||||
|
||||
// Build builds a binary packet from the current data.
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package mhfpacket
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"erupe-ce/common/byteframe"
|
||||
"erupe-ce/network"
|
||||
"erupe-ce/network/clientctx"
|
||||
@@ -33,5 +35,5 @@ func (m *MsgSysGetStageBinary) Parse(bf *byteframe.ByteFrame, ctx *clientctx.Cli
|
||||
|
||||
// Build builds a binary packet from the current data.
|
||||
func (m *MsgSysGetStageBinary) Build(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
||||
panic("Not implemented")
|
||||
return fmt.Errorf("MsgSysGetStageBinary.Build: not implemented")
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package mhfpacket
|
||||
|
||||
import (
|
||||
"erupe-ce/common/byteframe"
|
||||
"fmt"
|
||||
|
||||
"erupe-ce/common/bfutil"
|
||||
"erupe-ce/common/byteframe"
|
||||
"erupe-ce/network"
|
||||
"erupe-ce/network/clientctx"
|
||||
)
|
||||
@@ -31,5 +33,5 @@ func (m *MsgSysMoveStage) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientCo
|
||||
|
||||
// Build builds a binary packet from the current data.
|
||||
func (m *MsgSysMoveStage) Build(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
||||
panic("Not implemented")
|
||||
return fmt.Errorf("MsgSysMoveStage.Build: not implemented")
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package mhfpacket
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"erupe-ce/common/byteframe"
|
||||
"erupe-ce/network"
|
||||
"erupe-ce/network/clientctx"
|
||||
@@ -32,5 +34,5 @@ func (m *MsgSysSetStageBinary) Parse(bf *byteframe.ByteFrame, ctx *clientctx.Cli
|
||||
|
||||
// Build builds a binary packet from the current data.
|
||||
func (m *MsgSysSetStageBinary) Build(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
||||
panic("Not implemented")
|
||||
return fmt.Errorf("MsgSysSetStageBinary.Build: not implemented")
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package mhfpacket
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"erupe-ce/common/byteframe"
|
||||
"erupe-ce/network"
|
||||
"erupe-ce/network/clientctx"
|
||||
@@ -33,5 +35,5 @@ func (m *MsgSysWaitStageBinary) Parse(bf *byteframe.ByteFrame, ctx *clientctx.Cl
|
||||
|
||||
// Build builds a binary packet from the current data.
|
||||
func (m *MsgSysWaitStageBinary) Build(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
||||
panic("Not implemented")
|
||||
return fmt.Errorf("MsgSysWaitStageBinary.Build: not implemented")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user