summaryrefslogtreecommitdiffstats
path: root/src/userpref.c
diff options
context:
space:
mode:
authorGravatar Christophe Fergeau2008-08-10 22:53:46 +0200
committerGravatar Matt Colyer2008-08-11 09:34:46 -0700
commit1c920f3c8ec3466d23ba0d1ac417793d406cb11b (patch)
treede2fc7ae8f78db0addb22a61372fe98fc299d149 /src/userpref.c
parent3c052f02933ce1299f136b2d5fb2e6946bf9f1c5 (diff)
downloadlibimobiledevice-1c920f3c8ec3466d23ba0d1ac417793d406cb11b.tar.gz
libimobiledevice-1c920f3c8ec3466d23ba0d1ac417793d406cb11b.tar.bz2
Add missing g_free
Signed-off-by: Matt Colyer <matt@colyer.name>
Diffstat (limited to 'src/userpref.c')
-rw-r--r--src/userpref.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/userpref.c b/src/userpref.c
index c792d1f..f4a22fd 100644
--- a/src/userpref.c
+++ b/src/userpref.c
@@ -41,6 +41,7 @@ extern int debug;
41inline void create_config_dir() { 41inline void create_config_dir() {
42 gchar* config_dir = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, NULL); 42 gchar* config_dir = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, NULL);
43 g_mkdir_with_parents (config_dir, 755); 43 g_mkdir_with_parents (config_dir, 755);
44 g_free(config_dir);
44 return; 45 return;
45} 46}
46 47
@@ -59,6 +60,7 @@ char* get_host_id()
59 g_free(loc_host_id); 60 g_free(loc_host_id);
60 } 61 }
61 g_key_file_free(key_file); 62 g_key_file_free(key_file);
63 g_free(config_file);
62 64
63 if (debug) printf("Using %s as HostID\n",host_id); 65 if (debug) printf("Using %s as HostID\n",host_id);
64 return host_id; 66 return host_id;
@@ -95,11 +97,13 @@ int is_device_known(char* public_key)
95 g_io_channel_shutdown(keyfile, FALSE, NULL); 97 g_io_channel_shutdown(keyfile, FALSE, NULL);
96 pcur++; 98 pcur++;
97 } 99 }
100 g_free(keyfilepath);
98 } 101 }
99 } 102 }
100 g_strfreev(devices_list); 103 g_strfreev(devices_list);
101 } 104 }
102 g_key_file_free(key_file); 105 g_key_file_free(key_file);
106 g_free(config_file);
103 } 107 }
104 return ret; 108 return ret;
105} 109}
@@ -117,7 +121,7 @@ int store_device_public_key(char* public_key)
117 GKeyFile* key_file = g_key_file_new (); 121 GKeyFile* key_file = g_key_file_new ();
118 if( g_key_file_load_from_file (key_file, config_file, G_KEY_FILE_KEEP_COMMENTS, NULL) ) { 122 if( g_key_file_load_from_file (key_file, config_file, G_KEY_FILE_KEEP_COMMENTS, NULL) ) {
119 123
120 gchar** devices_list = g_key_file_get_string_list (key_file, "Global", "DevicesList", NULL, NULL); 124 gchar** devices_list = g_key_file_get_string_list (key_file, "Global", "DevicesList", NULL, NULL);
121 125
122 guint length = 0; 126 guint length = 0;
123 guint wlength = 0; 127 guint wlength = 0;
@@ -130,6 +134,7 @@ int store_device_public_key(char* public_key)
130 134
131 gchar* device_file = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, dev_file, NULL); 135 gchar* device_file = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, dev_file, NULL);
132 GIOChannel* file = g_io_channel_new_file (device_file, "w", NULL); 136 GIOChannel* file = g_io_channel_new_file (device_file, "w", NULL);
137 g_free (device_file);
133 wlength = strlen(public_key); // why this wasn't discovered before... ugh 138 wlength = strlen(public_key); // why this wasn't discovered before... ugh
134 g_io_channel_write_chars (file, public_key, wlength, NULL, NULL); 139 g_io_channel_write_chars (file, public_key, wlength, NULL, NULL);
135 g_io_channel_shutdown(file, TRUE, NULL); 140 g_io_channel_shutdown(file, TRUE, NULL);
@@ -197,7 +202,6 @@ int init_config_file(char* host_id, gnutls_datum_t* root_key, gnutls_datum_t* ho
197 if (!host_id || !root_key || !host_key || !root_cert || !host_cert) 202 if (!host_id || !root_key || !host_key || !root_cert || !host_cert)
198 return 0; 203 return 0;
199 204
200 gchar* config_file = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, LIBIPHONE_CONF_FILE, NULL);
201 /* make sure config directory exists*/ 205 /* make sure config directory exists*/
202 create_config_dir(); 206 create_config_dir();
203 207
@@ -211,7 +215,9 @@ int init_config_file(char* host_id, gnutls_datum_t* root_key, gnutls_datum_t* ho
211 /* write config file on disk */ 215 /* write config file on disk */
212 gsize length; 216 gsize length;
213 gchar* buf = g_key_file_to_data (key_file, &length,NULL); 217 gchar* buf = g_key_file_to_data (key_file, &length,NULL);
218 gchar* config_file = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, LIBIPHONE_CONF_FILE, NULL);
214 GIOChannel* file = g_io_channel_new_file (config_file, "w", NULL); 219 GIOChannel* file = g_io_channel_new_file (config_file, "w", NULL);
220 g_free (config_file);
215 g_io_channel_write_chars (file, buf, length, NULL, NULL); 221 g_io_channel_write_chars (file, buf, length, NULL, NULL);
216 g_io_channel_shutdown(file, TRUE, NULL); 222 g_io_channel_shutdown(file, TRUE, NULL);
217 223
@@ -224,21 +230,25 @@ int init_config_file(char* host_id, gnutls_datum_t* root_key, gnutls_datum_t* ho
224 pFile = fopen ( pem , "wb" ); 230 pFile = fopen ( pem , "wb" );
225 fwrite ( root_key->data, 1 , root_key->size , pFile ); 231 fwrite ( root_key->data, 1 , root_key->size , pFile );
226 fclose (pFile); 232 fclose (pFile);
233 g_free (pem);
227 234
228 pem = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, LIBIPHONE_HOST_PRIVKEY, NULL); 235 pem = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, LIBIPHONE_HOST_PRIVKEY, NULL);
229 pFile = fopen ( pem , "wb" ); 236 pFile = fopen ( pem , "wb" );
230 fwrite ( host_key->data, 1 , host_key->size , pFile ); 237 fwrite ( host_key->data, 1 , host_key->size , pFile );
231 fclose (pFile); 238 fclose (pFile);
239 g_free (pem);
232 240
233 pem = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, LIBIPHONE_ROOT_CERTIF, NULL); 241 pem = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, LIBIPHONE_ROOT_CERTIF, NULL);
234 pFile = fopen ( pem , "wb" ); 242 pFile = fopen ( pem , "wb" );
235 fwrite ( root_cert->data, 1 , root_cert->size , pFile ); 243 fwrite ( root_cert->data, 1 , root_cert->size , pFile );
236 fclose (pFile); 244 fclose (pFile);
245 g_free (pem);
237 246
238 pem = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, LIBIPHONE_HOST_CERTIF, NULL); 247 pem = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, LIBIPHONE_HOST_CERTIF, NULL);
239 pFile = fopen ( pem , "wb" ); 248 pFile = fopen ( pem , "wb" );
240 fwrite ( host_cert->data, 1 , host_cert->size , pFile ); 249 fwrite ( host_cert->data, 1 , host_cert->size , pFile );
241 fclose (pFile); 250 fclose (pFile);
251 g_free (pem);
242 252
243 return 1; 253 return 1;
244} 254}