diff --git a/binary/decoder.go b/binary/decoder.go index 3769134d..06868a14 100644 --- a/binary/decoder.go +++ b/binary/decoder.go @@ -251,6 +251,12 @@ func (r *binaryDecoder) readInteropJID() (interface{}, error) { if err != nil { return nil, err } + server, err := r.read(true) + if err != nil { + return nil, err + } else if server != types.InteropServer { + return nil, fmt.Errorf("%w: expected %q, got %q", ErrInvalidJIDType, types.InteropServer, server) + } return types.JID{ User: user.(string), Device: uint16(device), @@ -271,8 +277,8 @@ func (r *binaryDecoder) readFBJID() (interface{}, error) { server, err := r.read(true) if err != nil { return nil, err - } else if server == nil { - return nil, ErrInvalidJIDType + } else if server != types.MessengerServer { + return nil, fmt.Errorf("%w: expected %q, got %q", ErrInvalidJIDType, types.MessengerServer, server) } return types.JID{ User: user.(string),