GPCM: Fix error on empty match data

This commit is contained in:
mkwcat 2024-01-05 18:55:53 -05:00
parent db9eedf684
commit 3337d7fc0d
No known key found for this signature in database
GPG Key ID: 7A505679CE9E7AA9

View File

@ -318,6 +318,10 @@ func (g *GameSpySession) bestieMessage(command common.GameSpyCommand) {
switch version {
case 3:
if len(msg) == msgDataIndex {
break
}
for _, stringValue := range strings.Split(msg[msgDataIndex:], "/") {
intValue, err := strconv.ParseUint(stringValue, 10, 32)
if err != nil {
@ -330,6 +334,10 @@ func (g *GameSpySession) bestieMessage(command common.GameSpyCommand) {
}
case 11:
if len(msg) == msgDataIndex {
break
}
for _, stringValue := range strings.Split(msg[msgDataIndex:], "/") {
byteValue, err := hex.DecodeString(stringValue)
if err != nil || len(byteValue) != 4 {
@ -342,6 +350,10 @@ func (g *GameSpySession) bestieMessage(command common.GameSpyCommand) {
}
case 90:
if len(msg) == msgDataIndex {
break
}
msgData, err = common.Base64DwcEncoding.DecodeString(msg[msgDataIndex:])
if err != nil {
logging.Error(g.ModuleName, "Invalid message base64 data; message:", msg)