aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2010-08-26 14:33:03 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2010-08-26 14:33:03 +0000
commita52fe978a15db0438ba5534e73724f6308d60330 (patch)
tree1fb4d0058525f5898f65b64259405e9785dc3a29 /src
parentd90d66f22e4b3f227067a8f06cc7e0e994a38c2c (diff)
downloadgnunet-a52fe978a15db0438ba5534e73724f6308d60330.tar.gz
gnunet-a52fe978a15db0438ba5534e73724f6308d60330.zip
FIX: bugs found by klocwork
Diffstat (limited to 'src')
-rwxr-xr-xsrc/transport/benchmark.sh4
-rw-r--r--src/transport/plugin_transport_http.c6
-rw-r--r--src/transport/plugin_transport_https.c43
3 files changed, 19 insertions, 34 deletions
diff --git a/src/transport/benchmark.sh b/src/transport/benchmark.sh
index 2ce07e655..6ae68af2a 100755
--- a/src/transport/benchmark.sh
+++ b/src/transport/benchmark.sh
@@ -1,12 +1,12 @@
1#/bin/sh 1#/bin/sh
2 2
3for i in {1..10} 3for i in {1..0}
4do 4do
5 echo RUN $i 5 echo RUN $i
6 ./test_transport_api_reliability_http 6 ./test_transport_api_reliability_http
7done 7done
8 8
9for i in {1..10} 9for i in {1..100}
10do 10do
11 echo RUN $i 11 echo RUN $i
12 ./test_transport_api_reliability_https 12 ./test_transport_api_reliability_https
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c
index 2293e4ba4..952078865 100644
--- a/src/transport/plugin_transport_http.c
+++ b/src/transport/plugin_transport_http.c
@@ -419,13 +419,13 @@ static char * create_url(void * cls, const void * addr, size_t addrlen, size_t i
419{ 419{
420 struct Plugin *plugin = cls; 420 struct Plugin *plugin = cls;
421 char *url = NULL; 421 char *url = NULL;
422 char *addr_str = (char *) http_plugin_address_to_string(NULL, addr, addrlen);
422 423
423 GNUNET_assert ((addr!=NULL) && (addrlen != 0)); 424 GNUNET_assert ((addr!=NULL) && (addrlen != 0));
424 GNUNET_asprintf(&url, 425 GNUNET_asprintf(&url,
425 "%s://%s/%s;%u", PROTOCOL_PREFIX, 426 "%s://%s/%s;%u", PROTOCOL_PREFIX, addr_str,
426 http_plugin_address_to_string(NULL, addr, addrlen),
427 (char *) (&plugin->my_ascii_hash_ident),id); 427 (char *) (&plugin->my_ascii_hash_ident),id);
428 428 GNUNET_free_non_null(addr_str);
429 return url; 429 return url;
430} 430}
431 431
diff --git a/src/transport/plugin_transport_https.c b/src/transport/plugin_transport_https.c
index 088c8f3d8..ff87f3c94 100644
--- a/src/transport/plugin_transport_https.c
+++ b/src/transport/plugin_transport_https.c
@@ -429,13 +429,13 @@ static char * create_url(void * cls, const void * addr, size_t addrlen, size_t i
429{ 429{
430 struct Plugin *plugin = cls; 430 struct Plugin *plugin = cls;
431 char *url = NULL; 431 char *url = NULL;
432 char *addr_str = (char *) http_plugin_address_to_string(NULL, addr, addrlen);
432 433
433 GNUNET_assert ((addr!=NULL) && (addrlen != 0)); 434 GNUNET_assert ((addr!=NULL) && (addrlen != 0));
434 GNUNET_asprintf(&url, 435 GNUNET_asprintf(&url,
435 "%s://%s/%s;%u", PROTOCOL_PREFIX, 436 "%s://%s/%s;%u", PROTOCOL_PREFIX, addr_str,
436 http_plugin_address_to_string(NULL, addr, addrlen),
437 (char *) (&plugin->my_ascii_hash_ident),id); 437 (char *) (&plugin->my_ascii_hash_ident),id);
438 438 GNUNET_free_non_null(addr_str);
439 return url; 439 return url;
440} 440}
441 441
@@ -818,7 +818,7 @@ mdh_access_cb (void *cls,
818 818
819 int res = GNUNET_NO; 819 int res = GNUNET_NO;
820 int send_error_to_client; 820 int send_error_to_client;
821 void * addr; 821 void * addr = NULL;
822 size_t addr_len = 0; 822 size_t addr_len = 0;
823 823
824 GNUNET_assert(cls !=NULL); 824 GNUNET_assert(cls !=NULL);
@@ -2294,6 +2294,7 @@ load_certificate( const char * file )
2294 if (GNUNET_SYSERR == GNUNET_DISK_file_read(gn_file, text, fstat.st_size)) 2294 if (GNUNET_SYSERR == GNUNET_DISK_file_read(gn_file, text, fstat.st_size))
2295 { 2295 {
2296 GNUNET_free(text); 2296 GNUNET_free(text);
2297 GNUNET_DISK_file_close(gn_file);
2297 return NULL; 2298 return NULL;
2298 } 2299 }
2299 text[fstat.st_size] = '\0'; 2300 text[fstat.st_size] = '\0';
@@ -2367,6 +2368,8 @@ libgnunet_plugin_transport_https_done (void *cls)
2367 GNUNET_free_non_null (plugin->bind6_address); 2368 GNUNET_free_non_null (plugin->bind6_address);
2368 GNUNET_free_non_null (plugin->bind_hostname); 2369 GNUNET_free_non_null (plugin->bind_hostname);
2369 GNUNET_free_non_null (plugin->crypto_init); 2370 GNUNET_free_non_null (plugin->crypto_init);
2371 GNUNET_free_non_null (plugin->cert);
2372 GNUNET_free_non_null (plugin->key);
2370 GNUNET_free (plugin); 2373 GNUNET_free (plugin);
2371 GNUNET_free (api); 2374 GNUNET_free (api);
2372#if DEBUG_HTTPS 2375#if DEBUG_HTTPS
@@ -2388,8 +2391,8 @@ libgnunet_plugin_transport_https_init (void *cls)
2388 struct GNUNET_TIME_Relative gn_timeout; 2391 struct GNUNET_TIME_Relative gn_timeout;
2389 long long unsigned int port; 2392 long long unsigned int port;
2390 2393
2391 char * key_file; 2394 char * key_file = NULL;
2392 char * cert_file; 2395 char * cert_file = NULL;
2393 2396
2394 GNUNET_assert(cls !=NULL); 2397 GNUNET_assert(cls !=NULL);
2395#if DEBUG_HTTPS 2398#if DEBUG_HTTPS
@@ -2489,20 +2492,6 @@ libgnunet_plugin_transport_https_init (void *cls)
2489 2492
2490 /* Get private key file from config */ 2493 /* Get private key file from config */
2491 if (GNUNET_CONFIGURATION_have_value (env->cfg, 2494 if (GNUNET_CONFIGURATION_have_value (env->cfg,
2492 "transport-https", "CERT_FILE"))
2493 {
2494 GNUNET_CONFIGURATION_get_value_string (env->cfg,
2495 "transport-https",
2496 "CERT_FILE",
2497 &cert_file);
2498 }
2499 else
2500 {
2501 GNUNET_asprintf(&cert_file,"https.cert");
2502 }
2503
2504 /* Get private key file from config */
2505 if (GNUNET_CONFIGURATION_have_value (env->cfg,
2506 "transport-https", "KEY_FILE")) 2495 "transport-https", "KEY_FILE"))
2507 { 2496 {
2508 GNUNET_CONFIGURATION_get_value_string (env->cfg, 2497 GNUNET_CONFIGURATION_get_value_string (env->cfg,
@@ -2510,24 +2499,19 @@ libgnunet_plugin_transport_https_init (void *cls)
2510 "KEY_FILE", 2499 "KEY_FILE",
2511 &key_file); 2500 &key_file);
2512 } 2501 }
2513 else 2502 if (key_file==NULL)
2514 {
2515 GNUNET_asprintf(&key_file,"https.key"); 2503 GNUNET_asprintf(&key_file,"https.key");
2516 }
2517 2504
2518 /* Get private key file from config */ 2505 /* Get private key file from config */
2519 if (GNUNET_CONFIGURATION_have_value (env->cfg, 2506 if (GNUNET_CONFIGURATION_have_value (env->cfg,"transport-https", "CERT_FILE"))
2520 "transport-https", "CERT_FILE"))
2521 { 2507 {
2522 GNUNET_CONFIGURATION_get_value_string (env->cfg, 2508 GNUNET_CONFIGURATION_get_value_string (env->cfg,
2523 "transport-https", 2509 "transport-https",
2524 "CERT_FILE", 2510 "CERT_FILE",
2525 &cert_file); 2511 &cert_file);
2526 } 2512 }
2527 else 2513 if (cert_file==NULL)
2528 {
2529 GNUNET_asprintf(&cert_file,"https.cert"); 2514 GNUNET_asprintf(&cert_file,"https.cert");
2530 }
2531 2515
2532 /* Should plugin use ipv6? */ 2516 /* Should plugin use ipv6? */
2533 if ((plugin->use_ipv6==GNUNET_YES) && (GNUNET_CONFIGURATION_have_value (env->cfg, 2517 if ((plugin->use_ipv6==GNUNET_YES) && (GNUNET_CONFIGURATION_have_value (env->cfg,
@@ -2578,6 +2562,7 @@ libgnunet_plugin_transport_https_init (void *cls)
2578 "transport-https"); 2562 "transport-https");
2579 GNUNET_free (key_file); 2563 GNUNET_free (key_file);
2580 GNUNET_free (cert_file); 2564 GNUNET_free (cert_file);
2565
2581 libgnunet_plugin_transport_https_done(api); 2566 libgnunet_plugin_transport_https_done(api);
2582 GNUNET_free (cmd); 2567 GNUNET_free (cmd);
2583 return NULL; 2568 return NULL;
@@ -2606,7 +2591,7 @@ libgnunet_plugin_transport_https_init (void *cls)
2606 2591
2607 2592
2608 GNUNET_assert((plugin->key!=NULL) && (plugin->cert!=NULL)); 2593 GNUNET_assert((plugin->key!=NULL) && (plugin->cert!=NULL));
2609 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "TLS certificate loaded\n", key_file, cert_file); 2594 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "TLS certificate loaded\n");
2610 2595
2611 GNUNET_assert ((port > 0) && (port <= 65535)); 2596 GNUNET_assert ((port > 0) && (port <= 65535));
2612 plugin->port_inbound = port; 2597 plugin->port_inbound = port;