about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorDebXWoody <stefan@debxwoody.de>2021-06-29 20:25:50 +0200
committerDebXWoody <stefan@debxwoody.de>2021-06-29 20:25:50 +0200
commit6173e015f5e9b3751c94c03ac47fbdf8099cee24 (patch)
treeabab5f69a5890cc9ab670b0eb080fd378085625e
parent2a011e69acb97ba6e794f970c5d67a9e4b348bd7 (diff)
downloadprofani-tty-6173e015f5e9b3751c94c03ac47fbdf8099cee24.tar.gz
OX bug fixing
 * Don't decryption if there is no private key
 * Decryption error messages
-rw-r--r--src/pgp/gpg.c5
-rw-r--r--src/xmpp/message.c13
2 files changed, 12 insertions, 6 deletions
diff --git a/src/pgp/gpg.c b/src/pgp/gpg.c
index bb701c3f..8aac50ff 100644
--- a/src/pgp/gpg.c
+++ b/src/pgp/gpg.c
@@ -1141,6 +1141,11 @@ _ox_key_is_usable(gpgme_key_t key, const char* const barejid, gboolean secret)
 char*
 p_ox_gpg_decrypt(char* base64)
 {
+    // if there is no private key avaibale,
+    // we don't try do decrypt
+    if(!ox_is_private_key_available(connection_get_barejid())) {
+        return NULL;
+    }
     setlocale(LC_ALL, "");
     gpgme_check_version(NULL);
     gpgme_set_locale(NULL, LC_CTYPE, setlocale(LC_CTYPE, NULL));
diff --git a/src/xmpp/message.c b/src/xmpp/message.c
index 33e15e78..aad7107d 100644
--- a/src/xmpp/message.c
+++ b/src/xmpp/message.c
@@ -1463,28 +1463,29 @@ _handle_ox_chat(xmpp_stanza_t* const stanza, ProfMessage* message, gboolean is_m
                 xmpp_stanza_t *p =  xmpp_stanza_get_child_by_name(x, "payload");
                 if ( !p ) {
                     log_warning("OX Stanza - no Payload");
+                    message->plain = "OX error: No payload found";
                     return;
                 }
                 xmpp_stanza_t *b =  xmpp_stanza_get_child_by_name(p, "body");
                 if ( !b ) {
                     log_warning("OX Stanza - no body");
+                    message->plain = "OX error: No paylod body found";
                     return;
                 }
                 message->plain = xmpp_stanza_get_text(b);
-                if(message->plain == NULL ) {
-                    message->plain = xmpp_stanza_get_text(stanza);
-                }
                 message->encrypted = xmpp_stanza_get_text(ox);
-
-                if (message->plain == NULL) {
+                if(message->plain == NULL ) {
                     message->plain = xmpp_stanza_get_text(stanza);
                 }
-                message->encrypted = xmpp_stanza_get_text(ox);
             } else {
+                message->plain = "Unable to decrypt OX message (XEP-0373: OpenPGP for XMPP)";
                 log_warning("OX Stanza text to stanza failed");
             }
+        } else {
+            message->plain = "Unable to decrypt OX message (XEP-0373: OpenPGP for XMPP)";
         }
     } else {
+        message->plain = "OX stanza without openpgp name";
         log_warning("OX Stanza without openpgp stanza");
     }
 #endif // HAVE_LIBGPGME