diff options
author | Matthew Wild <mwild1@gmail.com> | 2008-12-05 02:02:57 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2008-12-05 02:02:57 +0000 |
commit | 7027c01125981f14eb4d117658036e20e0a8bccc (patch) | |
tree | 218b520b881b8cac75c206c8e1b58765066e7fa2 /net | |
parent | d55671436960cebe411a500062319203d7fcdd5e (diff) | |
download | prosody-7027c01125981f14eb4d117658036e20e0a8bccc.tar.gz prosody-7027c01125981f14eb4d117658036e20e0a8bccc.zip |
Disconnect with stream errors on bad XML, or invalid stream namespace
Diffstat (limited to 'net')
-rw-r--r-- | net/xmppclient_listener.lua | 16 | ||||
-rw-r--r-- | net/xmppserver_listener.lua | 16 |
2 files changed, 28 insertions, 4 deletions
diff --git a/net/xmppclient_listener.lua b/net/xmppclient_listener.lua index 470c23d2..33dcef10 100644 --- a/net/xmppclient_listener.lua +++ b/net/xmppclient_listener.lua @@ -36,7 +36,16 @@ local sm_streamopened = sessionmanager.streamopened; local sm_streamclosed = sessionmanager.streamclosed; local st = stanza; -local stream_callbacks = { streamopened = sm_streamopened, streamclosed = sm_streamclosed, handlestanza = core_process_stanza }; +local stream_callbacks = { ns = "http://etherx.jabber.org/streams", streamopened = sm_streamopened, streamclosed = sm_streamclosed, handlestanza = core_process_stanza }; + +function stream_callbacks.error(session, error, data) + if error == "no-stream" then + session:close("invalid-namespace"); + else + session.log("debug", "Client XML parse error: %s", tostring(error)); + session:close("xml-not-well-formed"); + end +end local sessions = {}; local xmppclient = { default_port = 5222, default_mode = "*a" }; @@ -51,8 +60,11 @@ local function session_reset_stream(session) session.notopen = true; function session.data(conn, data) - parser:parse(data); + local ok, err = parser:parse(data); + if ok then return; end + session:close("xml-not-well-formed"); end + return true; end diff --git a/net/xmppserver_listener.lua b/net/xmppserver_listener.lua index 4b41afbd..bdd3948d 100644 --- a/net/xmppserver_listener.lua +++ b/net/xmppserver_listener.lua @@ -28,7 +28,16 @@ local s2s_streamopened = require "core.s2smanager".streamopened; local s2s_streamclosed = require "core.s2smanager".streamclosed; local s2s_destroy_session = require "core.s2smanager".destroy_session; local s2s_attempt_connect = require "core.s2smanager".attempt_connection; -local stream_callbacks = { streamopened = s2s_streamopened, streamclosed = s2s_streamclosed, handlestanza = core_process_stanza }; +local stream_callbacks = { ns = "http://etherx.jabber.org/streams", streamopened = s2s_streamopened, streamclosed = s2s_streamclosed, handlestanza = core_process_stanza }; + +function stream_callbacks.error(session, error, data) + if error == "no-stream" then + session:close("invalid-namespace"); + else + session.log("debug", "Server-to-server XML parse error: %s", tostring(error)); + session:close("xml-not-well-formed"); + end +end local connlisteners_register = require "net.connlisteners".register; @@ -53,8 +62,11 @@ local function session_reset_stream(session) session.notopen = true; function session.data(conn, data) - parser:parse(data); + local ok, err = parser:parse(data); + if ok then return; end + session:close("xml-not-well-formed"); end + return true; end |