mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Remove temporary ciphertext file when finished
This commit is contained in:
parent
9d58472c8c
commit
04bfa23ead
@ -4862,7 +4862,8 @@ cmd_sendfile(ProfWin* window, const char* const command, gchar** args)
|
||||
|
||||
// Create temporary file for writing ciphertext.
|
||||
int tmpfd;
|
||||
if ((tmpfd = g_file_open_tmp("profanity.XXXXXX", NULL, NULL)) == -1) {
|
||||
char *tmpname = NULL;
|
||||
if ((tmpfd = g_file_open_tmp("profanity.XXXXXX", &tmpname, NULL)) == -1) {
|
||||
char *msg = "Unable to create temporary file for encrypted transfer.";
|
||||
cons_show_error(msg);
|
||||
win_println(window, THEME_ERROR, "-", msg);
|
||||
@ -4871,6 +4872,11 @@ cmd_sendfile(ProfWin* window, const char* const command, gchar** args)
|
||||
}
|
||||
FILE *tmpfh = fdopen(tmpfd, "wb");
|
||||
|
||||
// The temporary ciphertext file should be removed upon closure
|
||||
// later.
|
||||
remove(tmpname);
|
||||
free(tmpname);
|
||||
|
||||
int crypt_res;
|
||||
alt_scheme = OMEMO_AESGCM_URL_SCHEME;
|
||||
alt_fragment = omemo_encrypt_file(fh, tmpfh, file_size(fd), &crypt_res);
|
||||
@ -4889,7 +4895,7 @@ cmd_sendfile(ProfWin* window, const char* const command, gchar** args)
|
||||
|
||||
fclose(fh); // Also closes descriptor.
|
||||
|
||||
// Switch original stream with temporary encrypted stream.
|
||||
// Switch original stream with temporary ciphertext stream.
|
||||
fd = tmpfd;
|
||||
fh = tmpfh;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user