mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-22 07:32:32 +01:00
fix(channelserver): validate packet fields before use in handlers
Several handlers used packet fields as array indices or SQL column names without bounds checking, allowing crafted packets to panic the server or produce malformed SQL. Panic fixes (high severity): - handlers_mail: bounds check AccIndex against mailList length - handlers_misc: validate ArmourID >= 10000 and MogType <= 4 - handlers_mercenary: check RawDataPayload length before slicing - handlers_house: check RawDataPayload length in SaveDecoMyset - handlers_register: guard empty RawDataPayload in OperateRegister SQL column name fixes (medium severity): - handlers_misc: early return on unknown PointType - handlers_items: reject unknown StampType in weekly stamp handlers - handlers_achievement: cap AchievementID at 32 - handlers_goocoo: skip goocoo.Index > 4 - handlers_house: cap BoxIndex for warehouse operations - handlers_tower: fix MissionIndex=0 bypassing normalization guard
This commit is contained in:
@@ -43,6 +43,9 @@ func handleMsgMhfUpdateEtcPoint(s *Session, p mhfpacket.MHFPacket) {
|
||||
column = "daily_quests"
|
||||
case 2:
|
||||
column = "promo_points"
|
||||
default:
|
||||
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
|
||||
return
|
||||
}
|
||||
|
||||
var value int16
|
||||
@@ -187,9 +190,17 @@ func handleMsgMhfUpdateEquipSkinHist(s *Session, p mhfpacket.MHFPacket) {
|
||||
return
|
||||
}
|
||||
|
||||
if pkt.ArmourID < 10000 || pkt.MogType > 4 {
|
||||
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
|
||||
return
|
||||
}
|
||||
bit := int(pkt.ArmourID) - 10000
|
||||
startByte := (size / 5) * int(pkt.MogType)
|
||||
// psql set_bit could also work but I couldn't get it working
|
||||
sectionSize := size / 5
|
||||
if bit/8 >= sectionSize {
|
||||
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
|
||||
return
|
||||
}
|
||||
startByte := sectionSize * int(pkt.MogType)
|
||||
byteInd := bit / 8
|
||||
bitInByte := bit % 8
|
||||
data[startByte+byteInd] |= bits.Reverse8(1 << uint(bitInByte))
|
||||
|
||||
Reference in New Issue
Block a user