]> granicus.if.org Git - ejabberd/commitdiff
Guard against passing undefined C2SPid to xml parser before become_controller gets...
authorPaweł Chmielowski <pchmielowski@process-one.net>
Thu, 17 Sep 2015 09:36:45 +0000 (11:36 +0200)
committerPaweł Chmielowski <pchmielowski@process-one.net>
Thu, 17 Sep 2015 09:37:01 +0000 (11:37 +0200)
Our new nif xml parser don't handle this gracefully, so we better don't
call it that way.

This is only triggered on old style ssl sockets, where ssl layer must
be activated early, before association between socket and c2s is
established

src/ejabberd_receiver.erl

index f63ae1ccb916781cd59f072e7475192a98813e81..3f8f979dc128827f76bf4404544d44ced58272ea 100644 (file)
@@ -159,8 +159,13 @@ handle_call({starttls, TLSSocket}, _From,
                   c2s_pid = C2SPid,
                   max_stanza_size = MaxStanzaSize} = State) ->
     close_stream(XMLStreamState),
-    NewXMLStreamState = xml_stream:new(C2SPid,
-                                      MaxStanzaSize),
+    NewXMLStreamState = case C2SPid of
+                            undefined ->
+                                XMLStreamState;
+                            _ ->
+                                xml_stream:new(C2SPid,
+                                               MaxStanzaSize)
+                        end,
     NewState = State#state{socket = TLSSocket,
                           sock_mod = p1_tls,
                           xml_stream_state = NewXMLStreamState},
@@ -347,7 +352,12 @@ process_data(Data,
                    shaper_state = ShaperState, c2s_pid = C2SPid} =
                 State) ->
     ?DEBUG("Received XML on stream = ~p", [(Data)]),
-    XMLStreamState1 = xml_stream:parse(XMLStreamState, Data),
+    XMLStreamState1 = case XMLStreamState of
+                          undefined ->
+                              XMLStreamState;
+                          _ ->
+                              xml_stream:parse(XMLStreamState, Data)
+                      end,
     {NewShaperState, Pause} = shaper:update(ShaperState, byte_size(Data)),
     if
        C2SPid == undefined ->