# HG changeset patch # User Kim Alvefur # Date 1590956748 -7200 # Node ID 19e7092e062c7c9faebe8f7b23b7818c6e91ed15 # Parent 7fd8976d47d7a1865aad37a7eecb3a71c7486dc0 mod_c2s,mod_s2s: Use a distinct stream error for hitting stanza size limit Since this is not a real parse error, it should not be reported as such. diff -r 7fd8976d47d7 -r 19e7092e062c plugins/mod_c2s.lua --- a/plugins/mod_c2s.lua Wed May 27 19:44:12 2020 +0200 +++ b/plugins/mod_c2s.lua Sun May 31 22:25:48 2020 +0200 @@ -308,7 +308,11 @@ local ok, err = stream:feed(data); if not ok then log("debug", "Received invalid XML (%s) %d bytes: %q", err, #data, data:sub(1, 300)); - session:close("not-well-formed"); + if err == "stanza-too-large" then + session:close({ condition = "policy-violation", text = "XML stanza is too big" }); + else + session:close("not-well-formed"); + end end end end diff -r 7fd8976d47d7 -r 19e7092e062c plugins/mod_s2s/mod_s2s.lua --- a/plugins/mod_s2s/mod_s2s.lua Wed May 27 19:44:12 2020 +0200 +++ b/plugins/mod_s2s/mod_s2s.lua Sun May 31 22:25:48 2020 +0200 @@ -614,7 +614,11 @@ local ok, err = stream:feed(data); if ok then return; end log("debug", "Received invalid XML (%s) %d bytes: %q", err, #data, data:sub(1, 300)); - session:close("not-well-formed", nil, "Received invalid XML from remote server"); + if err == "stanza-too-large" then + session:close({ condition = "policy-violation", text = "XML stanza is too big" }, nil, "Received invalid XML from remote server"); + else + session:close("not-well-formed", nil, "Received invalid XML from remote server"); + end end end