aboutsummaryrefslogtreecommitdiff
path: root/src/nat
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2015-10-06 19:09:29 +0000
committerBart Polot <bart@net.in.tum.de>2015-10-06 19:09:29 +0000
commit74735f9ef6d47283feb58d8b5ca7209875150063 (patch)
tree550d68f5aeed84948ceedf438f4075ce3d58d5da /src/nat
parent79c1ca1481b8a0f98dbcff5ccab068fa624688ca (diff)
downloadgnunet-74735f9ef6d47283feb58d8b5ca7209875150063.tar.gz
gnunet-74735f9ef6d47283feb58d8b5ca7209875150063.zip
- fix use of uninitialized memory
Diffstat (limited to 'src/nat')
-rw-r--r--src/nat/gnunet-nat.c23
-rw-r--r--src/nat/nat_auto.c30
2 files changed, 26 insertions, 27 deletions
diff --git a/src/nat/gnunet-nat.c b/src/nat/gnunet-nat.c
index f9aae10cf..0c8fc1f5c 100644
--- a/src/nat/gnunet-nat.c
+++ b/src/nat/gnunet-nat.c
@@ -50,7 +50,7 @@ auto_conf_iter (void *cls,
50 const char *value) 50 const char *value)
51{ 51{
52 52
53 printf( "%s: %s \n", option, value); 53 PRINTF ( "%s: %s \n", option, value);
54} 54}
55 55
56 56
@@ -67,11 +67,11 @@ auto_conf_iter (void *cls,
67 67
68void 68void
69auto_config_cb(void *cls, 69auto_config_cb(void *cls,
70 const struct GNUNET_CONFIGURATION_Handle *diff, 70 const struct GNUNET_CONFIGURATION_Handle *diff,
71 enum GNUNET_NAT_StatusCode result, enum GNUNET_NAT_Type type) 71 enum GNUNET_NAT_StatusCode result, enum GNUNET_NAT_Type type)
72{ 72{
73 char* nat_type; 73 char* nat_type;
74 74 char unknown_type[64];
75 75
76 switch (type) 76 switch (type)
77 { 77 {
@@ -87,11 +87,13 @@ auto_config_cb(void *cls,
87 case GNUNET_NAT_TYPE_UPNP_NAT: 87 case GNUNET_NAT_TYPE_UPNP_NAT:
88 nat_type = "NAT but UPNP opened the ports"; 88 nat_type = "NAT but UPNP opened the ports";
89 break; 89 break;
90 90 default:
91 SPRINTF (unknown_type, "NAT unknown, type %u", type);
92 nat_type = unknown_type;
91 } 93 }
92 94
93 printf("NAT status: %s \n", nat_type ); 95 PRINTF ("NAT status: %s \n", nat_type );
94 printf("SUGGESTED CHANGES: \n" ); 96 PRINTF ("SUGGESTED CHANGES: \n" );
95 97
96 GNUNET_CONFIGURATION_iterate_section_values (diff, 98 GNUNET_CONFIGURATION_iterate_section_values (diff,
97 "nat", 99 "nat",
@@ -104,7 +106,7 @@ auto_config_cb(void *cls,
104 106
105 107
106 108
107 109
108 110
109/** 111/**
110 * Main function that will be run. 112 * Main function that will be run.
@@ -118,10 +120,7 @@ static void
118run (void *cls, char *const *args, const char *cfgfile, 120run (void *cls, char *const *args, const char *cfgfile,
119 const struct GNUNET_CONFIGURATION_Handle *c) 121 const struct GNUNET_CONFIGURATION_Handle *c)
120{ 122{
121 123 GNUNET_NAT_autoconfig_start (c, auto_config_cb, NULL);
122
123 GNUNET_NAT_autoconfig_start(c,auto_config_cb, NULL);
124
125} 124}
126 125
127 126
diff --git a/src/nat/nat_auto.c b/src/nat/nat_auto.c
index 4701d744e..a76bb0d1d 100644
--- a/src/nat/nat_auto.c
+++ b/src/nat/nat_auto.c
@@ -457,7 +457,7 @@ set_external_ipv4 (void *cls,
457 { 457 {
458 GNUNET_break (0); 458 GNUNET_break (0);
459 /* actually, this should never happen, as the caller already executed just 459 /* actually, this should never happen, as the caller already executed just
460 * this check, but for consistency (eg: future changes in the caller) 460 * this check, but for consistency (eg: future changes in the caller)
461 * we still need to report this error... 461 * we still need to report this error...
462 */ 462 */
463 ah->ret = GNUNET_NAT_ERROR_EXTERNAL_IP_ADDRESS_INVALID; 463 ah->ret = GNUNET_NAT_ERROR_EXTERNAL_IP_ADDRESS_INVALID;
@@ -481,7 +481,7 @@ test_external_ip (struct GNUNET_NAT_AutoHandle *ah)
481{ 481{
482 if (GNUNET_NAT_ERROR_SUCCESS != ah->ret) 482 if (GNUNET_NAT_ERROR_SUCCESS != ah->ret)
483 next_phase (ah); 483 next_phase (ah);
484 484
485 // FIXME: CPS? 485 // FIXME: CPS?
486 /* try to detect external IP */ 486 /* try to detect external IP */
487 ah->eh = GNUNET_NAT_mini_get_external_ipv4 (TIMEOUT, 487 ah->eh = GNUNET_NAT_mini_get_external_ipv4 (TIMEOUT,
@@ -628,7 +628,7 @@ test_local_ip (struct GNUNET_NAT_AutoHandle *ah)
628 ah->have_v6 = GNUNET_NO; 628 ah->have_v6 = GNUNET_NO;
629 ah->ret = GNUNET_NAT_ERROR_NO_VALID_IF_IP_COMBO; // reset to success if any of the IFs in below iterator has a valid IP 629 ah->ret = GNUNET_NAT_ERROR_NO_VALID_IF_IP_COMBO; // reset to success if any of the IFs in below iterator has a valid IP
630 GNUNET_OS_network_interfaces_list (&process_if, ah); 630 GNUNET_OS_network_interfaces_list (&process_if, ah);
631 631
632 GNUNET_CONFIGURATION_set_value_string (ah->cfg, "nat", "DISABLEV6", 632 GNUNET_CONFIGURATION_set_value_string (ah->cfg, "nat", "DISABLEV6",
633 (GNUNET_YES == ah->have_v6) ? "NO" : "YES"); 633 (GNUNET_YES == ah->have_v6) ? "NO" : "YES");
634 next_phase (ah); 634 next_phase (ah);
@@ -705,7 +705,7 @@ test_upnpc (struct GNUNET_NAT_AutoHandle *ah)
705 705
706 if (GNUNET_NAT_ERROR_SUCCESS != ah->ret) 706 if (GNUNET_NAT_ERROR_SUCCESS != ah->ret)
707 next_phase (ah); 707 next_phase (ah);
708 708
709 // test if upnpc is available 709 // test if upnpc is available
710 have_upnpc = (GNUNET_SYSERR != 710 have_upnpc = (GNUNET_SYSERR !=
711 GNUNET_OS_check_helper_binary ("upnpc", GNUNET_NO, NULL)); 711 GNUNET_OS_check_helper_binary ("upnpc", GNUNET_NO, NULL));
@@ -738,7 +738,7 @@ test_icmp_server (struct GNUNET_NAT_AutoHandle *ah)
738 ext_ip = GNUNET_NO; 738 ext_ip = GNUNET_NO;
739 nated = GNUNET_NO; 739 nated = GNUNET_NO;
740 binary = GNUNET_NO; 740 binary = GNUNET_NO;
741 741
742 tmp = NULL; 742 tmp = NULL;
743 helper = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-nat-server"); 743 helper = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-nat-server");
744 if ((GNUNET_OK == 744 if ((GNUNET_OK ==
@@ -749,7 +749,7 @@ test_icmp_server (struct GNUNET_NAT_AutoHandle *ah)
749 } 749 }
750 else 750 else
751 goto err; 751 goto err;
752 752
753 if (GNUNET_YES == 753 if (GNUNET_YES ==
754 GNUNET_CONFIGURATION_get_value_yesno (ah->cfg, "nat", "BEHIND_NAT")){ 754 GNUNET_CONFIGURATION_get_value_yesno (ah->cfg, "nat", "BEHIND_NAT")){
755 nated = GNUNET_YES; 755 nated = GNUNET_YES;
@@ -757,7 +757,7 @@ test_icmp_server (struct GNUNET_NAT_AutoHandle *ah)
757 } 757 }
758 else 758 else
759 goto err; 759 goto err;
760 760
761 if (GNUNET_YES == 761 if (GNUNET_YES ==
762 GNUNET_OS_check_helper_binary (helper, GNUNET_YES, "-d 127.0.0.1" )){ 762 GNUNET_OS_check_helper_binary (helper, GNUNET_YES, "-d 127.0.0.1" )){
763 binary = GNUNET_OK; // use localhost as source for that one udp-port, ok for testing 763 binary = GNUNET_OK; // use localhost as source for that one udp-port, ok for testing
@@ -798,14 +798,14 @@ test_icmp_client (struct GNUNET_NAT_AutoHandle *ah)
798 } 798 }
799 else 799 else
800 goto err; 800 goto err;
801 801
802 if (GNUNET_YES != 802 if (GNUNET_YES !=
803 GNUNET_CONFIGURATION_get_value_yesno (ah->cfg, "nat", "BEHIND_NAT")){ 803 GNUNET_CONFIGURATION_get_value_yesno (ah->cfg, "nat", "BEHIND_NAT")){
804 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("test_icmp_server not possible, as we are not behind NAT\n")); 804 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("test_icmp_server not possible, as we are not behind NAT\n"));
805 } 805 }
806 else 806 else
807 goto err; 807 goto err;
808 808
809 if (GNUNET_YES == 809 if (GNUNET_YES ==
810 GNUNET_OS_check_helper_binary (helper, GNUNET_YES, "-d 127.0.0.1 127.0.0.2 42")){ 810 GNUNET_OS_check_helper_binary (helper, GNUNET_YES, "-d 127.0.0.1 127.0.0.2 42")){
811 // none of these parameters are actually used in privilege testing mode 811 // none of these parameters are actually used in privilege testing mode
@@ -864,11 +864,11 @@ next_phase (struct GNUNET_NAT_AutoHandle *ah)
864 break; 864 break;
865 case AUTO_DONE: 865 case AUTO_DONE:
866 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Done with tests\n"); 866 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Done with tests\n");
867 if(!ah->internal_ip_is_public) 867 if (!ah->internal_ip_is_public)
868 { 868 {
869 GNUNET_CONFIGURATION_set_value_string (ah->cfg, "nat", "BEHIND_NAT", "YES"); 869 GNUNET_CONFIGURATION_set_value_string (ah->cfg, "nat", "BEHIND_NAT", "YES");
870 870
871 if(ah->connected_back) 871 if (ah->connected_back)
872 { 872 {
873 GNUNET_CONFIGURATION_set_value_string (ah->cfg, "nat", "PUNCHED_NAT", "YES"); 873 GNUNET_CONFIGURATION_set_value_string (ah->cfg, "nat", "PUNCHED_NAT", "YES");
874 } 874 }
@@ -881,7 +881,7 @@ next_phase (struct GNUNET_NAT_AutoHandle *ah)
881 { 881 {
882 GNUNET_CONFIGURATION_set_value_string (ah->cfg, "nat", "EXTERNAL_ADDRESS", 882 GNUNET_CONFIGURATION_set_value_string (ah->cfg, "nat", "EXTERNAL_ADDRESS",
883 ah->stun_ip); 883 ah->stun_ip);
884 if(ah->connected_back) 884 if (ah->connected_back)
885 { 885 {
886 ah->type = GNUNET_NAT_TYPE_STUN_PUNCHED_NAT; 886 ah->type = GNUNET_NAT_TYPE_STUN_PUNCHED_NAT;
887 GNUNET_CONFIGURATION_set_value_string (ah->cfg, "nat", "USE_STUN", "YES"); 887 GNUNET_CONFIGURATION_set_value_string (ah->cfg, "nat", "USE_STUN", "YES");
@@ -893,7 +893,7 @@ next_phase (struct GNUNET_NAT_AutoHandle *ah)
893 } 893 }
894 894
895 } 895 }
896 if(ah->stun_port) 896 if (ah->stun_port)
897 { 897 {
898 GNUNET_CONFIGURATION_set_value_number (ah->cfg, "transport-udp", 898 GNUNET_CONFIGURATION_set_value_number (ah->cfg, "transport-udp",
899 "ADVERTISED_PORT", 899 "ADVERTISED_PORT",
@@ -904,7 +904,7 @@ next_phase (struct GNUNET_NAT_AutoHandle *ah)
904 else 904 else
905 { 905 {
906 //The internal IP is the same as public, but we didn't got a incoming connection 906 //The internal IP is the same as public, but we didn't got a incoming connection
907 if(ah->connected_back) 907 if (ah->connected_back)
908 { 908 {
909 ah->type = GNUNET_NAT_TYPE_NO_NAT; 909 ah->type = GNUNET_NAT_TYPE_NO_NAT;
910 GNUNET_CONFIGURATION_set_value_string (ah->cfg, "nat", "BEHIND_NAT", "NO"); 910 GNUNET_CONFIGURATION_set_value_string (ah->cfg, "nat", "BEHIND_NAT", "NO");
@@ -918,7 +918,7 @@ next_phase (struct GNUNET_NAT_AutoHandle *ah)
918 GNUNET_CONFIGURATION_set_value_string (ah->cfg, "nat", "EXTERNAL_ADDRESS", 918 GNUNET_CONFIGURATION_set_value_string (ah->cfg, "nat", "EXTERNAL_ADDRESS",
919 ah->stun_ip); 919 ah->stun_ip);
920 } 920 }
921 if(ah->stun_port) 921 if (ah->stun_port)
922 { 922 {
923 GNUNET_CONFIGURATION_set_value_number (ah->cfg, "transport-udp", 923 GNUNET_CONFIGURATION_set_value_number (ah->cfg, "transport-udp",
924 "ADVERTISED_PORT", 924 "ADVERTISED_PORT",