5757#include "ui/window.h"
5858#include "common.h"
5959
60- #define FALLBACK_MSG ""
61-
6260void *
6361aesgcm_file_get (void * userdata )
6462{
6563 AESGCMDownload * aesgcm_dl = (AESGCMDownload * )userdata ;
6664
67- char * https_url = NULL ;
68- char * fragment = NULL ;
65+ auto_char char * https_url = NULL ;
66+ auto_char char * fragment = NULL ;
6967
7068 // Convert the aesgcm:// URL to a https:// URL and extract the encoded key
7169 // and tag stored in the URL fragment.
@@ -79,8 +77,8 @@ aesgcm_file_get(void* userdata)
7977
8078 // Create a temporary file used for storing the ciphertext that is to be
8179 // retrieved from the https:// URL.
82- gchar * tmpname = NULL ;
83- gint tmpfd ;
80+ auto_gchar char * tmpname = NULL ;
81+ auto_gfd gint tmpfd = 0 ;
8482 if ((tmpfd = g_file_open_tmp ("profanity.XXXXXX" , & tmpname , NULL )) == -1 ) {
8583 http_print_transfer_update (aesgcm_dl -> window , aesgcm_dl -> id ,
8684 "Downloading '%s' failed: Unable to create "
@@ -91,7 +89,7 @@ aesgcm_file_get(void* userdata)
9189 }
9290
9391 // Open the target file for storing the cleartext.
94- FILE * outfh = fopen (aesgcm_dl -> filename , "wb" );
92+ auto_FILE FILE * outfh = fopen (aesgcm_dl -> filename , "wb" );
9593 if (outfh == NULL ) {
9694 http_print_transfer_update (aesgcm_dl -> window , aesgcm_dl -> id ,
9795 "Downloading '%s' failed: Unable to open "
@@ -115,7 +113,7 @@ aesgcm_file_get(void* userdata)
115113
116114 http_file_get (http_dl ); // TODO(wstrm): Verify result.
117115
118- FILE * tmpfh = fopen (tmpname , "rb" );
116+ auto_FILE FILE * tmpfh = fopen (tmpname , "rb" );
119117 if (tmpfh == NULL ) {
120118 http_print_transfer_update (aesgcm_dl -> window , aesgcm_dl -> id ,
121119 "Downloading '%s' failed: Unable to open "
@@ -129,11 +127,6 @@ aesgcm_file_get(void* userdata)
129127 crypt_res = omemo_decrypt_file (tmpfh , outfh ,
130128 http_dl -> bytes_received , fragment );
131129
132- if (fclose (tmpfh ) == EOF ) {
133- cons_show_error (g_strerror (errno ));
134- }
135-
136- close (tmpfd );
137130 remove (tmpname );
138131 g_free (tmpname );
139132
@@ -144,13 +137,6 @@ aesgcm_file_get(void* userdata)
144137 https_url , gcry_strerror (crypt_res ));
145138 }
146139
147- if (fclose (outfh ) == EOF ) {
148- cons_show_error (g_strerror (errno ));
149- }
150-
151- free (https_url );
152- free (fragment );
153-
154140 if (aesgcm_dl -> cmd_template != NULL ) {
155141 gchar * * argv = format_call_external_argv (aesgcm_dl -> cmd_template ,
156142 aesgcm_dl -> filename ,
0 commit comments