# HG changeset patch # User Emmanuel Gil Peyrot # Date 1641581703 -3600 # Node ID 3804332c204eab0b1927a576978fed1ef85ca3c6 # Parent 810b0e17d3aabf75c6bc9f762b7ef7d024478395 mod_tcpproxy: Reject missing or non-number block-size, as per XEP-0047 diff -r 810b0e17d3aa -r 3804332c204e mod_tcpproxy/README.markdown --- a/mod_tcpproxy/README.markdown Thu Jan 06 17:45:15 2022 +0100 +++ b/mod_tcpproxy/README.markdown Fri Jan 07 19:55:03 2022 +0100 @@ -39,16 +39,17 @@ ``` {.xml} ``` -The stanza attribute (currently) MUST be 'message', and a block-size, if -given, is (currently) ignored. +The stanza attribute (currently) MUST be 'message', and block-size is +(currently) ignored. In response to this stanza you will receive a result upon connection success, or an error if the connection failed. You can then send to the @@ -67,6 +68,6 @@ ==== - ACLs (restrict to certain JIDs, and/or certain target hosts/ports) -- Honour block-size (undecided) +- Honour block-size - Support iq stanzas for data transmission - Signal to start SSL/TLS on a connection diff -r 810b0e17d3aa -r 3804332c204e mod_tcpproxy/mod_tcpproxy.lua --- a/mod_tcpproxy/mod_tcpproxy.lua Thu Jan 06 17:45:15 2022 +0100 +++ b/mod_tcpproxy/mod_tcpproxy.lua Fri Jan 07 19:55:03 2022 +0100 @@ -44,13 +44,16 @@ if ibb_tag.name == "open" then -- Starting a new stream local to_host, to_port = ibb_tag.attr[host_attr], ibb_tag.attr[port_attr]; - local jid, sid = stanza.attr.from, ibb_tag.attr.sid; + local jid, sid, block_size = stanza.attr.from, ibb_tag.attr.sid, ibb_tag.attr["block-size"]; if not (to_host and to_port) then origin.send(st.error_reply(stanza, "modify", "bad-request", "No host/port specified")); return true; elseif not sid or sid == "" then origin.send(st.error_reply(stanza, "modify", "bad-request", "No sid specified")); return true; + elseif not block_size or not tonumber(block_size) then + origin.send(st.error_reply(stanza, "modify", "bad-request", "Bad block-size attribute")); + return true; elseif ibb_tag.attr.stanza ~= "message" then origin.send(st.error_reply(stanza, "modify", "bad-request", "Only 'message' stanza transport is supported")); return true;