aboutsummaryrefslogtreecommitdiff
path: root/src/testcurl/https/tls_authentication_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testcurl/https/tls_authentication_test.c')
-rw-r--r--src/testcurl/https/tls_authentication_test.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/testcurl/https/tls_authentication_test.c b/src/testcurl/https/tls_authentication_test.c
index 900d20de..7f576654 100644
--- a/src/testcurl/https/tls_authentication_test.c
+++ b/src/testcurl/https/tls_authentication_test.c
@@ -144,39 +144,39 @@ test_daemon_get (FILE * test_fd, char *cipher_suite, int proto_version)
144 doc_path_len = PATH_MAX > 4096 ? 4096 : PATH_MAX; 144 doc_path_len = PATH_MAX > 4096 ? 4096 : PATH_MAX;
145 if (NULL == (doc_path = malloc (doc_path_len))) 145 if (NULL == (doc_path = malloc (doc_path_len)))
146 { 146 {
147 fclose (test_fd);
148 fprintf (stderr, MHD_E_MEM); 147 fprintf (stderr, MHD_E_MEM);
149 return -1; 148 return -1;
150 } 149 }
151 if (getcwd (doc_path, doc_path_len) == NULL) 150 if (getcwd (doc_path, doc_path_len) == NULL)
152 { 151 {
153 fclose (test_fd);
154 free (doc_path);
155 fprintf (stderr, "Error: failed to get working directory. %s\n", 152 fprintf (stderr, "Error: failed to get working directory. %s\n",
156 strerror (errno)); 153 strerror (errno));
154 free (doc_path);
157 return -1; 155 return -1;
158 } 156 }
159 157
160 if (NULL == (mem_test_file_local = malloc (len))) 158 if (NULL == (mem_test_file_local = malloc (len)))
161 { 159 {
162 fclose (test_fd);
163 fprintf (stderr, MHD_E_MEM); 160 fprintf (stderr, MHD_E_MEM);
161 free (doc_path);
164 return -1; 162 return -1;
165 } 163 }
166 164
167 fseek (test_fd, 0, SEEK_SET); 165 fseek (test_fd, 0, SEEK_SET);
168 if (fread (mem_test_file_local, sizeof (char), len, test_fd) != len) 166 if (fread (mem_test_file_local, sizeof (char), len, test_fd) != len)
169 { 167 {
170 fclose (test_fd);
171 fprintf (stderr, "Error: failed to read test file. %s\n", 168 fprintf (stderr, "Error: failed to read test file. %s\n",
172 strerror (errno)); 169 strerror (errno));
170 free (doc_path);
171 free (mem_test_file_local);
173 return -1; 172 return -1;
174 } 173 }
175 174
176 if (NULL == (cbc.buf = malloc (sizeof (char) * len))) 175 if (NULL == (cbc.buf = malloc (sizeof (char) * len)))
177 { 176 {
178 fclose (test_fd);
179 fprintf (stderr, MHD_E_MEM); 177 fprintf (stderr, MHD_E_MEM);
178 free (doc_path);
179 free (mem_test_file_local);
180 return -1; 180 return -1;
181 } 181 }
182 cbc.size = len; 182 cbc.size = len;
@@ -218,6 +218,9 @@ test_daemon_get (FILE * test_fd, char *cipher_suite, int proto_version)
218 fprintf (stderr, "curl_easy_perform failed: `%s'\n", 218 fprintf (stderr, "curl_easy_perform failed: `%s'\n",
219 curl_easy_strerror (errornum)); 219 curl_easy_strerror (errornum));
220 curl_easy_cleanup (c); 220 curl_easy_cleanup (c);
221 free (cbc.buf);
222 free (doc_path);
223 free (mem_test_file_local);
221 return errornum; 224 return errornum;
222 } 225 }
223 226
@@ -228,6 +231,7 @@ test_daemon_get (FILE * test_fd, char *cipher_suite, int proto_version)
228 fprintf (stderr, "Error: local file & received file differ.\n"); 231 fprintf (stderr, "Error: local file & received file differ.\n");
229 free (cbc.buf); 232 free (cbc.buf);
230 free (mem_test_file_local); 233 free (mem_test_file_local);
234 free (doc_path);
231 return -1; 235 return -1;
232 } 236 }
233 237
@@ -308,12 +312,14 @@ setup_ca_cert ()
308 { 312 {
309 fprintf (stderr, "Error: failed to write `%s. %s'\n", 313 fprintf (stderr, "Error: failed to write `%s. %s'\n",
310 ca_cert_file_name, strerror (errno)); 314 ca_cert_file_name, strerror (errno));
315 fclose (test_fd);
311 return NULL; 316 return NULL;
312 } 317 }
313 if (fflush (fd)) 318 if (fflush (fd))
314 { 319 {
315 fprintf (stderr, "Error: failed to flush ca cert file stream. %s\n", 320 fprintf (stderr, "Error: failed to flush ca cert file stream. %s\n",
316 strerror (errno)); 321 strerror (errno));
322 fclose (test_fd);
317 return NULL; 323 return NULL;
318 } 324 }
319 325
@@ -342,6 +348,7 @@ main (int argc, char *const *argv)
342 if (0 != curl_global_init (CURL_GLOBAL_ALL)) 348 if (0 != curl_global_init (CURL_GLOBAL_ALL))
343 { 349 {
344 fprintf (stderr, "Error (code: %u)\n", errorCount); 350 fprintf (stderr, "Error (code: %u)\n", errorCount);
351 fclose (test_fd);
345 return -1; 352 return -1;
346 } 353 }
347 354