Software /
code /
prosody
Changeset
10849:19e7092e062c
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.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 31 May 2020 22:25:48 +0200 |
parents | 10848:7fd8976d47d7 |
children | 10850:bd2814f900dd |
files | plugins/mod_c2s.lua plugins/mod_s2s/mod_s2s.lua |
diffstat | 2 files changed, 10 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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