about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorPaul Fariello <paul@fariello.eu>2019-01-21 15:02:54 +0100
committerPaul Fariello <paul@fariello.eu>2019-01-21 15:02:54 +0100
commitac2d1c07fa26bb2d2c0a9428905f2de736342f2e (patch)
tree54dcff43fbf867f5f558f9139a284561291e9cdd /src
parent1cb045e30ca23c37ebf24718542010f3a57bad0c (diff)
downloadprofani-tty-ac2d1c07fa26bb2d2c0a9428905f2de736342f2e.tar.gz
Fix optionnal sessionid in xep 0050
Diffstat (limited to 'src')
-rw-r--r--src/xmpp/iq.c7
-rw-r--r--src/xmpp/stanza.c4
2 files changed, 9 insertions, 2 deletions
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index e5a74fc4..16824015 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -1226,10 +1226,15 @@ _command_exec_response_handler(xmpp_stanza_t *const stanza, void *const userdata
             win_command_exec_error(win, command, "Unsupported command response");
             return 0;
         }
+        const char *sessionid = xmpp_stanza_get_attribute(cmd, "sessionid");
 
         DataForm *form = form_create(x);
         CommandConfigData *data = malloc(sizeof(CommandConfigData));
-        data->sessionid = strdup(xmpp_stanza_get_attribute(cmd, "sessionid"));
+        if (sessionid == NULL) {
+            data->sessionid = NULL;
+        } else {
+            data->sessionid = strdup(sessionid);
+        }
         data->command = command;
         ProfConfWin *confwin = (ProfConfWin*)wins_new_config(from, form, iq_submit_command_config, iq_cancel_command_config, data);
         confwin_handle_configuration(confwin, form);
diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c
index c44433ef..26192b29 100644
--- a/src/xmpp/stanza.c
+++ b/src/xmpp/stanza.c
@@ -2078,7 +2078,9 @@ stanza_create_command_config_submit_iq(xmpp_ctx_t *ctx, const char *const room,
     xmpp_stanza_set_name(command, STANZA_NAME_COMMAND);
     xmpp_stanza_set_ns(command, STANZA_NS_COMMAND);
     xmpp_stanza_set_attribute(command, "node", node);
-    xmpp_stanza_set_attribute(command, "sessionid", sessionid);
+    if (sessionid != NULL) {
+        xmpp_stanza_set_attribute(command, "sessionid", sessionid);
+    }
 
     xmpp_stanza_t *x = form_create_submission(form);
     xmpp_stanza_add_child(command, x);