BurmistrovJ / prosody-modules

Automatically exported from code.google.com/p/prosody-modules
MIT License
0 stars 0 forks source link

mod_smacks call 'clone' function for stanza with attr field being nil, causing error #63

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run prosody (0.9 or 0.10) server with mod_smacks enabled
2. Connect to server with Gajim - this works, then exit Gajim
3. Connect to server with Gajim second time (from the same computer) - 
connection does not proceed

What is the expected output? What do you see instead?
That the second connection would succeed. Instead prosody log shows error:

Oct 06 14:25:53 c2sb28d20       error   Traceback[c2s]: 
/usr/lib/prosody/util/stanza.lua:342: bad argument #1 to 'pairs' (table expec
ted, got nil)
stack traceback:
        [C]: in function 'pairs'
        /usr/lib/prosody/util/stanza.lua:342: in function 'clone'
        /usr/lib/prosody/modules/mod_smacks/mod_smacks.lua:87: in function 'send'
        /usr/lib/prosody/modules/mod_c2s.lua:150: in function </usr/lib/prosody/modules/mod_c2s.lua:125>
        (tail call): ?
        /usr/lib/prosody/core/sessionmanager.lua:142: in function 'sm_bind_resource'
        /usr/lib/prosody/modules/mod_saslauth.lua:267: in function '?'
        /usr/lib/prosody/util/events.lua:67: in function </usr/lib/prosody/util/events.lua:63>
        (tail call): ?
        /usr/lib/prosody/modules/mod_iq.lua:54: in function '?'
        /usr/lib/prosody/util/events.lua:67: in function 'fire_event'
        /usr/lib/prosody/core/stanza_router.lua:188: in function 'core_post_stanza'
        /usr/lib/prosody/core/stanza_router.lua:135: in function 'core_process_stanza'
        /usr/lib/prosody/modules/mod_c2s.lua:236: in function 'func'
        /usr/lib/prosody/util/async.lua:88: in function </usr/lib/prosody/util/async.lua:86>

What version of the product are you using? On what operating system?
Linux debian wheezy, prosody 0.9 or 0.10,
mod_smacks latest (Revision: 8ac4438925cf)
Gajim 0.16 (compiled from the source)

Please provide any additional information below.
The problem is introduced in the last commit (8ac4438925cf) on lines 85-87 of 
mod_smacks.lua. In the previous version (feca77ad88ac)

local attr = stanza.attr;
if attr and not attr.xmlns then -- Stanza in default stream namespace   
    local cached_stanza = st.clone(stanza);

the code after 'then' is not executed if stanza.attr is nil. In the new version

local xmlns = stanza.attr and stanza.attr.xmlns;
if not xmlns then -- Stanza in default stream namespace
    local cached_stanza = st.clone(stanza);

the code is executed if stanza.attr is nil and this causes error in st.clone 
function which does not deal with this properly.

This bug might uncover other possible bugs:
(i) The st.clone function from prosody is not able to clone arbitrary stanza 
without errors.
(ii) Where from does the stanza with nil attr appear? 

Original issue reported on code.google.com by velt...@gmail.com on 7 Oct 2014 at 1:39

GoogleCodeExporter commented 9 years ago
Duplication of issue 62, sorry. But hopefully with more information.

Original comment by velt...@gmail.com on 7 Oct 2014 at 1:50