aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2020-05-31 22:25:48 +0200
committerKim Alvefur <zash@zash.se>2020-05-31 22:25:48 +0200
commitc79e73ffbe417e73c9d40d15337fb74e505b8939 (patch)
tree4937f14d1382dddb1fe62e9ec3c8c8528ade3550
parent0c1ed35de130c079f26a97ca56e8baf8662cbd7b (diff)
downloadprosody-c79e73ffbe417e73c9d40d15337fb74e505b8939.tar.gz
prosody-c79e73ffbe417e73c9d40d15337fb74e505b8939.zip
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.
-rw-r--r--plugins/mod_c2s.lua6
-rw-r--r--plugins/mod_s2s/mod_s2s.lua6
2 files changed, 10 insertions, 2 deletions
diff --git a/plugins/mod_c2s.lua b/plugins/mod_c2s.lua
index 91e37c4a..c6a95e9e 100644
--- a/plugins/mod_c2s.lua
+++ b/plugins/mod_c2s.lua
@@ -308,7 +308,11 @@ function listener.onconnect(conn)
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 --git a/plugins/mod_s2s/mod_s2s.lua b/plugins/mod_s2s/mod_s2s.lua
index 9f7d4d6d..bd6627b8 100644
--- a/plugins/mod_s2s/mod_s2s.lua
+++ b/plugins/mod_s2s/mod_s2s.lua
@@ -614,7 +614,11 @@ local function initialize_session(session)
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