25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

Fix bug when clients connect using legacy ssl

(ejabberd_receiver:process_data/2 was called before initializing  the xmlstream).

SVN Revision: 1933
This commit is contained in:
Pablo Polvorin 2009-03-01 20:18:42 +00:00
parent 3336d66fc4
commit f0d55c9a3f
2 changed files with 25 additions and 17 deletions

View File

@ -3,6 +3,10 @@
* src/ejabberd_auth_anonymous.erl: Host argument for ejabberd_hooks's * src/ejabberd_auth_anonymous.erl: Host argument for ejabberd_hooks's
functions must be in binary() format. functions must be in binary() format.
* src/ejabberd_receiver.erl: Fix bug when clients connect using legacy
ssl (ejabberd_receiver:process_data/2 was called before initializing
the xmlstream).
2009-02-28 Badlop <badlop@process-one.net> 2009-02-28 Badlop <badlop@process-one.net>
* src/mod_pubsub/node_default.erl: Fix that non-subscriber could * src/mod_pubsub/node_default.erl: Fix that non-subscriber could

View File

@ -132,9 +132,8 @@ init([Socket, SockMod, Shaper, MaxStanzaSize]) ->
%% {stop, Reason, State} %% {stop, Reason, State}
%% Description: Handling call messages %% Description: Handling call messages
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
handle_call({starttls, TLSSocket}, _From, handle_call({starttls, TLSSocket}, _From, State) ->
#state{xml_stream_state = XMLStreamState} = State) -> NewXMLStreamState = do_reset_stream(State),
NewXMLStreamState = do_reset_stream(XMLStreamState),
NewState = State#state{socket = TLSSocket, NewState = State#state{socket = TLSSocket,
sock_mod = tls, sock_mod = tls,
xml_stream_state = NewXMLStreamState}, xml_stream_state = NewXMLStreamState},
@ -165,17 +164,8 @@ handle_call(reset_stream, _From,
{reply, Reply, State#state{xml_stream_state = NewXMLStreamState}, {reply, Reply, State#state{xml_stream_state = NewXMLStreamState},
?HIBERNATE_TIMEOUT}; ?HIBERNATE_TIMEOUT};
handle_call({become_controller, C2SPid}, _From, State) -> handle_call({become_controller, C2SPid}, _From, State) ->
Parser = exmpp_xml:start_parser([ close_stream(State#state.xml_stream_state),
{names_as_atom, true}, XMLStreamState = new_xmlstream(C2SPid, State#state.max_stanza_size),
{check_nss, xmpp},
{check_elems, xmpp},
{check_attrs, xmpp},
{max_size, State#state.max_stanza_size}
]),
XMLStreamState = exmpp_xmlstream:start(
{gen_fsm, C2SPid}, Parser,
[{xmlstreamstart, new}]
),
NewState = State#state{c2s_pid = C2SPid, NewState = State#state{c2s_pid = C2SPid,
xml_stream_state = XMLStreamState}, xml_stream_state = XMLStreamState},
activate_socket(NewState), activate_socket(NewState),
@ -327,8 +317,22 @@ close_stream(XMLStreamState) ->
exmpp_xmlstream:stop(XMLStreamState). exmpp_xmlstream:stop(XMLStreamState).
do_reset_stream(undefined) -> do_reset_stream(#state{xml_stream_state = undefined, c2s_pid = C2SPid, max_stanza_size = MaxStanzaSize}) ->
undefined; new_xmlstream(C2SPid, MaxStanzaSize);
do_reset_stream(XMLStreamState) -> do_reset_stream(#state{xml_stream_state = XMLStreamState}) ->
exmpp_xmlstream:reset(XMLStreamState). exmpp_xmlstream:reset(XMLStreamState).
new_xmlstream(C2SPid, MaxStanzaSize) ->
Parser = exmpp_xml:start_parser([
{names_as_atom, true},
{check_nss, xmpp},
{check_elems, xmpp},
{check_attrs, xmpp},
{max_size, MaxStanzaSize}
]),
exmpp_xmlstream:start(
{gen_fsm, C2SPid}, Parser,
[{xmlstreamstart, new}]
).