Skip to content

Commit

Permalink
Don't try to use stable resources when client don't send user-agent
Browse files Browse the repository at this point in the history
This fixes crash in case of client sending bind2 tag but no user-agent,
as we tried to use missing user-agent to generate stable resource.
  • Loading branch information
prefiks committed Mar 6, 2024
1 parent 7672a7e commit 1b1418a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/xmpp_stream_in.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1168,8 +1168,9 @@ process_bind2(#{sasl2_ua_id := UAId, user := User, server := Server} = State, El
#bind2_bind{tag = Tag, sub_els = SubEls} ->
{Resource, SessionId} =
case {Tag, UAId} of
{undefined, undefined} -> {<<>>, undefined};
{<<>>, undefined} -> {<<>>, undefined};
{undefined, _} -> {<<>>, undefined};
{_, undefined} -> {<<>>, undefined};
{<<>>, _} -> {<<>>, undefined};
_ ->
Hash = crypto:hash(sha, <<"salt", User/binary, Server/binary, UAId/binary>>),
B64Hash = base64:encode(Hash),
Expand Down

0 comments on commit 1b1418a

Please sign in to comment.