diff options
author | Kim Alvefur <zash@zash.se> | 2018-12-29 03:21:13 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2018-12-29 03:21:13 +0100 |
commit | 5eb327274aa1ab27ec45b49e419943c264bd237d (patch) | |
tree | af1b603bcedd6e5853d15ce1cb5261a68b2eb7d8 /plugins | |
parent | e6b7c91ebc9484c268fd5f0632abf4eb475ad7d6 (diff) | |
download | prosody-5eb327274aa1ab27ec45b49e419943c264bd237d.tar.gz prosody-5eb327274aa1ab27ec45b49e419943c264bd237d.zip |
mod_admin_telnet: Validate hostnames in xmpp:ping command
Attempt to ping some invalid hostnames cause weird behavior
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mod_admin_telnet.lua | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/plugins/mod_admin_telnet.lua b/plugins/mod_admin_telnet.lua index ee6a4176..f3731c8a 100644 --- a/plugins/mod_admin_telnet.lua +++ b/plugins/mod_admin_telnet.lua @@ -1088,8 +1088,17 @@ def_env.xmpp = {}; local st = require "util.stanza"; local new_id = require "util.id".medium; function def_env.xmpp:ping(localhost, remotehost, timeout) - if not prosody.hosts[localhost] then - return nil, "No such host"; + localhost = select(2, jid_split(localhost)); + remotehost = select(2, jid_split(remotehost)); + if not localhost then + return nil, "Invalid sender hostname"; + elseif not prosody.hosts[localhost] then + return nil, "No such local host"; + end + if not remotehost then + return nil, "Invalid destination hostname"; + elseif prosody.hosts[remotehost] then + return nil, "Both hosts are local"; end local iq = st.iq{ from=localhost, to=remotehost, type="get", id=new_id()} :tag("ping", {xmlns="urn:xmpp:ping"}); |