mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 21:15:32 +09:00
fix(gateway): stop a non-map opcode payload crashing the socket (#2277)
This commit is contained in:
1 parent
04e150e4bf
commit
7ce3d71c44
3 files changed
+23
-3
No files matched your search
@@ -56,9 +56,13 @@ handle_authenticated_opcode(presence_update, Data, #{session_pid := Pid} = State
|
||||
->
|
||||
handle_presence_update(Data, Pid, State);
|
||||
handle_authenticated_opcode(voice_state_update, Data, #{session_pid := Pid} = State) when
|
||||
is_pid(Pid)
|
||||
is_pid(Pid), is_map(Data)
|
||||
->
|
||||
gateway_handler_voice:handle_voice_state_update(Pid, Data, State);
|
||||
handle_authenticated_opcode(voice_state_update, _Data, State) ->
|
||||
gateway_handler_encode:close_with_reason(
|
||||
decode_error, <<"Invalid voice payload">>, State
|
||||
);
|
||||
handle_authenticated_opcode(request_guild_members, Data, #{session_pid := Pid} = State) when
|
||||
is_pid(Pid)
|
||||
->
|
||||
|
||||
@@ -151,7 +151,7 @@ maybe_put(Key, Value, Map) ->
|
||||
{ok, binary(), map(), term(), [binary()], non_neg_integer(), integer() | undefined,
|
||||
gateway_sharding:shard() | undefined}
|
||||
| {error, atom()}.
|
||||
validate_identify_data(Data) ->
|
||||
validate_identify_data(Data) when is_map(Data) ->
|
||||
try
|
||||
Token = maps:get(<<"token">>, Data),
|
||||
Properties = maps:get(<<"properties">>, Data),
|
||||
@@ -163,7 +163,9 @@ validate_identify_data(Data) ->
|
||||
)
|
||||
catch
|
||||
error:{badkey, _} -> {error, missing_required_field}
|
||||
end.
|
||||
end;
|
||||
validate_identify_data(_Data) ->
|
||||
{error, invalid_data}.
|
||||
|
||||
-spec validate_properties(binary(), term(), term(), term(), term(), map()) ->
|
||||
{ok, binary(), map(), term(), [binary()], non_neg_integer(), integer() | undefined,
|
||||
|
||||
Reference in new issue
Block a user