From ff763a751b4dcd12181bd76be8534cdea7661a40 Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Mon, 19 Oct 2015 15:25:55 +0200 Subject: [PATCH] MT#15837 mod_sipwise_vcard_cusax: add error when no info is retrive This removes the lua error when trying to access nil value info.user http://xmpp.org/rfcs/rfc6120.html#stanzas-error-conditions Change-Id: Id5709fd4f2b234b6062a6f5433799d35fb90b7f3 --- plugins/mod_sipwise_vcard_cusax.lua | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/plugins/mod_sipwise_vcard_cusax.lua b/plugins/mod_sipwise_vcard_cusax.lua index 94151c4..aea0d3d 100644 --- a/plugins/mod_sipwise_vcard_cusax.lua +++ b/plugins/mod_sipwise_vcard_cusax.lua @@ -145,10 +145,21 @@ local function handle_vcard(event) user = session.username; host = session.host; end + if not (user and host) then + module:log("error", "bad-request stanza: %s", + tostring(stanza)) + session.send(st.error_reply(stanza, "modify", "jid-malformed")); + end local info = vcard.get_subscriber_info(user, host); - local vCard = generate_vcard(info); - local reply = st.reply(stanza):add_child(st.deserialize(vCard)); - session.send(reply); + if info then + local vCard = generate_vcard(info); + local reply = st.reply(stanza):add_child(st.deserialize(vCard)); + session.send(reply); + else + module:log("error", "No info retrieve from stanza: %s", + tostring(stanza)) + session.send(st.error_reply(stanza, "cancel", "item-not-found")); + end else module:log("debug", "reject setting vcard"); session.send(st.error_reply(stanza, "auth", "forbidden"));