]> granicus.if.org Git - ejabberd/commitdiff
Update incoming stanzas counter on invalid XML
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>
Thu, 15 Feb 2018 12:42:55 +0000 (15:42 +0300)
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>
Thu, 15 Feb 2018 12:42:55 +0000 (15:42 +0300)
src/mod_stream_mgmt.erl

index d295053f56fc59f01a91bc0c0fb3b246027ea244..549a15df6ab370ebf5df0670882e937bdb2a347f 100644 (file)
@@ -176,7 +176,8 @@ c2s_authenticated_packet(#{mgmt_state := MgmtState} = State, Pkt)
 c2s_authenticated_packet(State, Pkt) ->
     update_num_stanzas_in(State, Pkt).
 
-c2s_handle_recv(#{lang := Lang} = State, El, {error, Why}) ->
+c2s_handle_recv(#{mgmt_state := MgmtState,
+                 lang := Lang} = State, El, {error, Why}) ->
     Xmlns = xmpp:get_ns(El),
     IsStanza = xmpp:is_stanza(El),
     if Xmlns == ?NS_STREAM_MGMT_2; Xmlns == ?NS_STREAM_MGMT_3 ->
@@ -185,12 +186,13 @@ c2s_handle_recv(#{lang := Lang} = State, El, {error, Why}) ->
                             text = xmpp:mk_text(Txt, Lang),
                             xmlns = Xmlns},
            send(State, Err);
-       IsStanza ->
+       IsStanza andalso (MgmtState == pending orelse MgmtState == active) ->
+           State1 = update_num_stanzas_in(State, El),
            case xmpp:get_type(El) of
-               <<"result">> -> State;
-               <<"error">> -> State;
+               <<"result">> -> State1;
+               <<"error">> -> State1;
                _ ->
-                   State#{mgmt_is_resent => false}
+                   State1#{mgmt_is_resent => false}
            end;
        true ->
            State