25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

XEP-0198: Cope with invalid 'from'/'to' attributes

Check whether the 'from' and 'to' attributes are valid before bouncing
or resending a stanza from the stream management queue.  They might be
invalid in certain corner cases.

Thanks to Evgeniy for spotting this.
This commit is contained in:
Holger Weiss 2016-10-06 23:20:45 +02:00
parent 0ae84a646f
commit e54ba3db5b

View File

@ -2998,10 +2998,13 @@ handle_unacked_stanzas(#state{mgmt_state = MgmtState} = StateData, F)
lists:foreach( lists:foreach(
fun({_, Time, #xmlel{attrs = Attrs} = El}) -> fun({_, Time, #xmlel{attrs = Attrs} = El}) ->
From_s = fxml:get_attr_s(<<"from">>, Attrs), From_s = fxml:get_attr_s(<<"from">>, Attrs),
From = jid:from_string(From_s),
To_s = fxml:get_attr_s(<<"to">>, Attrs), To_s = fxml:get_attr_s(<<"to">>, Attrs),
To = jid:from_string(To_s), case {jid:from_string(From_s), jid:from_string(To_s)} of
F(From, To, El, Time) {#jid{} = From, #jid{} = To} ->
F(From, To, El, Time);
{_, _} ->
?DEBUG("Dropping stanza due to invalid JID(s)", [])
end
end, queue:to_list(Queue)) end, queue:to_list(Queue))
end; end;
handle_unacked_stanzas(_StateData, _F) -> handle_unacked_stanzas(_StateData, _F) ->