summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/userpref.c29
1 files changed, 8 insertions, 21 deletions
diff --git a/src/userpref.c b/src/userpref.c
index 1dfc6ff..c792d1f 100644
--- a/src/userpref.c
+++ b/src/userpref.c
@@ -162,27 +162,14 @@ int read_file_in_confdir(char* file, gnutls_datum_t* data)
162 return 0; 162 return 0;
163 163
164 gchar* filepath = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, file, NULL); 164 gchar* filepath = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, file, NULL);
165 if (g_file_test(filepath, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))) { 165 gboolean success;
166 166 gsize size;
167 FILE * pFile; 167 char *content;
168 168 success = g_file_get_contents (filepath, &content, &size, NULL);
169 pFile = fopen ( filepath , "rb" ); 169 g_free (filepath);
170 if (pFile==NULL) 170 data->data = content;
171 return 0; 171 data->size = size;
172 172 return success;
173 fseek (pFile , 0 , SEEK_END);
174 data->size = ftell (pFile);
175 rewind (pFile);
176
177 data->data = (char*)gnutls_malloc(data->size);
178 if (data->data == NULL)
179 return 0;
180
181 // copy the file into the buffer:
182 fread (data->data,1,data->size,pFile);
183 fclose (pFile);
184 }
185 return 1;
186} 173}
187 174
188int get_root_private_key(gnutls_datum_t* root_privkey) 175int get_root_private_key(gnutls_datum_t* root_privkey)