gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r36454 - gnunet/src/nat


From: gnunet
Subject: [GNUnet-SVN] r36454 - gnunet/src/nat
Date: Tue, 6 Oct 2015 21:09:29 +0200

Author: bartpolot
Date: 2015-10-06 21:09:29 +0200 (Tue, 06 Oct 2015)
New Revision: 36454

Modified:
   gnunet/src/nat/gnunet-nat.c
   gnunet/src/nat/nat_auto.c
Log:
- fix use of uninitialized memory

Modified: gnunet/src/nat/gnunet-nat.c
===================================================================
--- gnunet/src/nat/gnunet-nat.c 2015-10-06 17:50:47 UTC (rev 36453)
+++ gnunet/src/nat/gnunet-nat.c 2015-10-06 19:09:29 UTC (rev 36454)
@@ -50,7 +50,7 @@
                 const char *value)
 {
 
-  printf( "%s: %s \n", option, value);
+  PRINTF ( "%s: %s \n", option, value);
 }
 
 
@@ -67,12 +67,12 @@
 
 void
 auto_config_cb(void *cls,
-                                 const struct GNUNET_CONFIGURATION_Handle 
*diff,
-                                 enum GNUNET_NAT_StatusCode result, enum 
GNUNET_NAT_Type type)
+               const struct GNUNET_CONFIGURATION_Handle *diff,
+               enum GNUNET_NAT_StatusCode result, enum GNUNET_NAT_Type type)
 {
   char* nat_type;
+  char unknown_type[64];
 
-
   switch (type)
   {
     case GNUNET_NAT_TYPE_NO_NAT:
@@ -87,11 +87,13 @@
     case GNUNET_NAT_TYPE_UPNP_NAT:
       nat_type = "NAT but UPNP opened the ports";
       break;
-
+    default:
+      SPRINTF (unknown_type, "NAT unknown, type %u", type);
+      nat_type = unknown_type;
   }
 
-  printf("NAT status: %s \n", nat_type );
-  printf("SUGGESTED CHANGES: \n" );
+  PRINTF ("NAT status: %s \n", nat_type );
+  PRINTF ("SUGGESTED CHANGES: \n" );
 
   GNUNET_CONFIGURATION_iterate_section_values (diff,
                                                "nat",
@@ -104,8 +106,8 @@
 
 
 
-                                                                
 
+
 /**
  * Main function that will be run.
  *
@@ -118,10 +120,7 @@
 run (void *cls, char *const *args, const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *c)
 {
-  
-
-  GNUNET_NAT_autoconfig_start(c,auto_config_cb, NULL);
-
+  GNUNET_NAT_autoconfig_start (c, auto_config_cb, NULL);
 }
 
 

Modified: gnunet/src/nat/nat_auto.c
===================================================================
--- gnunet/src/nat/nat_auto.c   2015-10-06 17:50:47 UTC (rev 36453)
+++ gnunet/src/nat/nat_auto.c   2015-10-06 19:09:29 UTC (rev 36454)
@@ -457,7 +457,7 @@
   {
     GNUNET_break (0);
     /* actually, this should never happen, as the caller already executed just
-     * this check, but for consistency (eg: future changes in the caller) 
+     * this check, but for consistency (eg: future changes in the caller)
      * we still need to report this error...
      */
     ah->ret = GNUNET_NAT_ERROR_EXTERNAL_IP_ADDRESS_INVALID;
@@ -481,7 +481,7 @@
 {
   if (GNUNET_NAT_ERROR_SUCCESS != ah->ret)
     next_phase (ah);
-  
+
   // FIXME: CPS?
   /* try to detect external IP */
   ah->eh = GNUNET_NAT_mini_get_external_ipv4 (TIMEOUT,
@@ -628,7 +628,7 @@
   ah->have_v6 = GNUNET_NO;
   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
   GNUNET_OS_network_interfaces_list (&process_if, ah);
-  
+
   GNUNET_CONFIGURATION_set_value_string (ah->cfg, "nat", "DISABLEV6",
                                         (GNUNET_YES == ah->have_v6) ? "NO" : 
"YES");
   next_phase (ah);
@@ -705,7 +705,7 @@
 
   if (GNUNET_NAT_ERROR_SUCCESS != ah->ret)
     next_phase (ah);
-  
+
   // test if upnpc is available
   have_upnpc = (GNUNET_SYSERR !=
                GNUNET_OS_check_helper_binary ("upnpc", GNUNET_NO, NULL));
@@ -738,7 +738,7 @@
   ext_ip = GNUNET_NO;
   nated = GNUNET_NO;
   binary = GNUNET_NO;
-  
+
   tmp = NULL;
   helper = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-nat-server");
   if ((GNUNET_OK ==
@@ -749,7 +749,7 @@
   }
   else
     goto err;
-    
+
   if (GNUNET_YES ==
         GNUNET_CONFIGURATION_get_value_yesno (ah->cfg, "nat", "BEHIND_NAT")){
     nated = GNUNET_YES;
@@ -757,7 +757,7 @@
   }
   else
     goto err;
-  
+
   if (GNUNET_YES ==
         GNUNET_OS_check_helper_binary (helper, GNUNET_YES, "-d 127.0.0.1" )){
     binary = GNUNET_OK; // use localhost as source for that one udp-port, ok 
for testing
@@ -798,7 +798,7 @@
   }
   else
     goto err;
-  
+
   if (GNUNET_YES !=
       GNUNET_CONFIGURATION_get_value_yesno (ah->cfg, "nat", "BEHIND_NAT")){
     GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("test_icmp_server not possible, as 
we are not behind NAT\n"));
@@ -805,7 +805,7 @@
   }
   else
     goto err;
-  
+
   if (GNUNET_YES ==
       GNUNET_OS_check_helper_binary (helper, GNUNET_YES, "-d 127.0.0.1 
127.0.0.2 42")){
           // none of these parameters are actually used in privilege testing 
mode
@@ -864,11 +864,11 @@
     break;
   case AUTO_DONE:
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Done with tests\n");
-    if(!ah->internal_ip_is_public)
+    if (!ah->internal_ip_is_public)
     {
       GNUNET_CONFIGURATION_set_value_string (ah->cfg, "nat", "BEHIND_NAT", 
"YES");
 
-      if(ah->connected_back)
+      if (ah->connected_back)
       {
         GNUNET_CONFIGURATION_set_value_string (ah->cfg, "nat", "PUNCHED_NAT", 
"YES");
       }
@@ -881,7 +881,7 @@
       {
         GNUNET_CONFIGURATION_set_value_string (ah->cfg, "nat", 
"EXTERNAL_ADDRESS",
                                                ah->stun_ip);
-        if(ah->connected_back)
+        if (ah->connected_back)
         {
           ah->type = GNUNET_NAT_TYPE_STUN_PUNCHED_NAT;
           GNUNET_CONFIGURATION_set_value_string (ah->cfg, "nat", "USE_STUN", 
"YES");
@@ -893,7 +893,7 @@
         }
 
       }
-      if(ah->stun_port)
+      if (ah->stun_port)
       {
         GNUNET_CONFIGURATION_set_value_number (ah->cfg, "transport-udp",
                                                "ADVERTISED_PORT",
@@ -904,7 +904,7 @@
     else
     {
       //The internal IP is the same as public, but we didn't got a incoming 
connection
-      if(ah->connected_back)
+      if (ah->connected_back)
       {
         ah->type = GNUNET_NAT_TYPE_NO_NAT;
         GNUNET_CONFIGURATION_set_value_string (ah->cfg, "nat", "BEHIND_NAT", 
"NO");
@@ -918,7 +918,7 @@
           GNUNET_CONFIGURATION_set_value_string (ah->cfg, "nat", 
"EXTERNAL_ADDRESS",
                                                  ah->stun_ip);
         }
-        if(ah->stun_port)
+        if (ah->stun_port)
         {
           GNUNET_CONFIGURATION_set_value_number (ah->cfg, "transport-udp",
                                                  "ADVERTISED_PORT",




reply via email to

[Prev in Thread] Current Thread [Next in Thread]