fix gacha rewards overflowing

This commit is contained in:
wish
2023-02-18 10:43:47 +11:00
parent 8e6fa5e349
commit c3306de2ee

View File

@@ -600,7 +600,8 @@ func handleMsgMhfReceiveGachaItem(s *Session, p mhfpacket.MHFPacket) {
data = []byte{0x00} data = []byte{0x00}
} }
if data[0] > 36 { // I think there are still some edge cases where rewards can be nulled via overflow
if data[0] > 36 || len(data) > 181 {
resp := byteframe.NewByteFrame() resp := byteframe.NewByteFrame()
resp.WriteUint8(36) resp.WriteUint8(36)
resp.WriteBytes(data[1:181]) resp.WriteBytes(data[1:181])
@@ -610,7 +611,7 @@ func handleMsgMhfReceiveGachaItem(s *Session, p mhfpacket.MHFPacket) {
} }
if !pkt.Freeze { if !pkt.Freeze {
if data[0] > 36 { if data[0] > 36 || len(data) > 181 {
update := byteframe.NewByteFrame() update := byteframe.NewByteFrame()
update.WriteUint8(uint8(len(data[181:]) / 5)) update.WriteUint8(uint8(len(data[181:]) / 5))
update.WriteBytes(data[181:]) update.WriteBytes(data[181:])