about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorWilliam Wennerström <william@wstrm.dev>2020-06-28 14:36:16 +0200
committerWilliam Wennerström <william@wstrm.dev>2020-11-16 21:58:08 +0100
commite98644f631b516e38dd4142103356ceb31628aab (patch)
treed5706dfd8fe06b45b00c22f54a650391f05c57aa /src
parentfc6136ddf005553960257ae2b4a625116cf3513a (diff)
downloadprofani-tty-e98644f631b516e38dd4142103356ceb31628aab.tar.gz
Add guards for OMEMO
Diffstat (limited to 'src')
-rw-r--r--src/command/cmd_funcs.c22
-rw-r--r--src/tools/http_upload.c4
2 files changed, 21 insertions, 5 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 0f74ff7c..f000ae1e 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -4858,6 +4858,7 @@ cmd_sendfile(ProfWin* window, const char* const command, gchar** args)
             ProfChatWin *chatwin = (ProfChatWin*)window;
             assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
 
+#ifdef HAVE_OMEMO
             if (chatwin->is_omemo && !prefs_get_boolean(PREF_OMEMO_SENDFILE)) {
 
                 // Create temporary file for writing ciphertext.
@@ -4871,7 +4872,7 @@ cmd_sendfile(ProfWin* window, const char* const command, gchar** args)
                 }
                 FILE *tmpfh = fdopen(tmpfd, "wb");
 
-                int crypt_res = GPG_ERR_NO_ERROR;
+                int crypt_res;
                 alt_scheme = AES256_GCM_URL_SCHEME;
                 alt_fragment = aes256gcm_encrypt_file(fh, tmpfh, file_size(fd), &crypt_res);
                 if (crypt_res != 0) {
@@ -4895,10 +4896,11 @@ cmd_sendfile(ProfWin* window, const char* const command, gchar** args)
 
                 break;
             }
+#endif
 
             if ((chatwin->pgp_send && !prefs_get_boolean(PREF_PGP_SENDFILE))
                     || (chatwin->is_otr && !prefs_get_boolean(PREF_OTR_SENDFILE))) {
-                cons_show_error("Uploading unencrypted files disabled. See /omemo sendfile, /otr sendfile, /pgp sendfile.");
+                cons_show_error("Uploading unencrypted files disabled. See /otr sendfile or /pgp sendfile.");
                 win_println(window, THEME_ERROR, "-", "Sending encrypted files via http_upload is not possible yet.");
                 goto out;
             }
@@ -4929,14 +4931,26 @@ cmd_sendfile(ProfWin* window, const char* const command, gchar** args)
     upload->filehandle = fh;
     upload->filesize = file_size(fd);
     upload->mime_type = file_mime_type(filename);
-    upload->alt_scheme = strdup(alt_scheme);
-    upload->alt_fragment = strdup(alt_fragment);
+
+    if (alt_scheme != NULL) {
+        upload->alt_scheme = strdup(alt_scheme);
+    } else {
+        upload->alt_scheme = NULL;
+    }
+
+    if (alt_fragment != NULL) {
+        upload->alt_fragment = strdup(alt_fragment);
+    } else {
+        upload->alt_fragment = NULL;
+    }
 
     iq_http_upload_request(upload);
 
 out:
+#ifdef HAVE_OMEMO
     if (alt_fragment != NULL)
         aes256gcm_fragment_free(alt_fragment);
+#endif
     if (filename != NULL)
         free(filename);
 
diff --git a/src/tools/http_upload.c b/src/tools/http_upload.c
index d9742e30..8d369f8a 100644
--- a/src/tools/http_upload.c
+++ b/src/tools/http_upload.c
@@ -286,7 +286,9 @@ http_file_put(void *userdata)
             char *url = NULL;
             if (format_alt_url(upload->get_url, upload->alt_scheme, upload->alt_fragment, &url) != 0) {
                 char *msg;
-                asprintf(&msg, "Uploading '%s' failed: Bad URL ('%s')", upload->filename, upload->get_url);
+                if (asprintf(&msg, "Uploading '%s' failed: Bad URL ('%s')", upload->filename, upload->get_url)== -1) {
+                    msg = strdup(FALLBACK_MSG);
+                }
                 cons_show_error(msg);
                 free(msg);
             } else {