diff options
author | William Wennerström <william@wstrm.dev> | 2020-06-28 14:36:16 +0200 |
---|---|---|
committer | William Wennerström <william@wstrm.dev> | 2020-11-16 21:58:08 +0100 |
commit | e98644f631b516e38dd4142103356ceb31628aab (patch) | |
tree | d5706dfd8fe06b45b00c22f54a650391f05c57aa /src/command | |
parent | fc6136ddf005553960257ae2b4a625116cf3513a (diff) | |
download | profani-tty-e98644f631b516e38dd4142103356ceb31628aab.tar.gz |
Add guards for OMEMO
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/cmd_funcs.c | 22 |
1 files changed, 18 insertions, 4 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); |