- fix use of uninitialized memory
[oweals/gnunet.git] / src / dns / gnunet-helper-dns.c
index 8ff6413f8843cd66fd1784c5c6ad174b42767c23..b36972ac7ebcd0abd087d27c8927821e941c0a01 100644 (file)
@@ -1,6 +1,6 @@
 /*
    This file is part of GNUnet.
-   (C) 2010, 2011, 2012 Christian Grothoff
+   Copyright (C) 2010, 2011, 2012 Christian Grothoff
 
    GNUnet is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published
@@ -14,8 +14,8 @@
 
    You should have received a copy of the GNU General Public License
    along with GNUnet; see the file COPYING.  If not, write to the
-   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.
+   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.
 */
 
 /**
@@ -240,7 +240,7 @@ fork_and_exec (const char *file,
 
 
 /**
- * Creates a tun-interface called dev;
+ * Creates a tun-interface called @a dev;
  *
  * @param dev is asumed to point to a char[IFNAMSIZ]
  *        if *dev == '\\0', uses the name supplied by the kernel;
@@ -291,7 +291,7 @@ init_tun (char *dev)
 
 
 /**
- * @brief Sets the IPv6-Address given in address on the interface dev
+ * @brief Sets the IPv6-Address given in @a address on the interface @a dev
  *
  * @param dev the interface to configure
  * @param address the IPv6-Address
@@ -388,7 +388,7 @@ set_address6 (const char *dev, const char *address, unsigned long prefix_len)
 
 
 /**
- * @brief Sets the IPv4-Address given in address on the interface dev
+ * @brief Sets the IPv4-Address given in @a address on the interface @a dev
  *
  * @param dev the interface to configure
  * @param address the IPv4-Address
@@ -838,6 +838,9 @@ main (int argc, char *const*argv)
     }
   }
   if ( (SIG_ERR == signal (SIGTERM, &signal_handler)) ||
+#if (SIGTERM != GNUNET_TERM_SIG)
+       (SIG_ERR == signal (GNUNET_TERM_SIG, &signal_handler)) ||
+#endif
        (SIG_ERR == signal (SIGINT, &signal_handler)) ||
        (SIG_ERR == signal (SIGHUP, &signal_handler)) )
   {
@@ -875,6 +878,9 @@ main (int argc, char *const*argv)
   {
     fprintf (stderr, "Fatal: could not initialize tun-interface\n");
     (void) signal (SIGTERM, SIG_IGN);
+#if (SIGTERM != GNUNET_TERM_SIG)
+    (void) signal (GNUNET_TERM_SIG, SIG_IGN);
+#endif
     (void) signal (SIGINT, SIG_IGN);
     (void) signal (SIGHUP, SIG_IGN);
     (void) close (cpipe[0]);
@@ -891,6 +897,9 @@ main (int argc, char *const*argv)
     {
       fprintf (stderr, "Fatal: prefix_len out of range\n");
       (void) signal (SIGTERM, SIG_IGN);
+#if (SIGTERM != GNUNET_TERM_SIG)
+    (void) signal (GNUNET_TERM_SIG, SIG_IGN);
+#endif
       (void) signal (SIGINT, SIG_IGN);
       (void) signal (SIGHUP, SIG_IGN);
       (void) close (cpipe[0]);
@@ -999,7 +1008,7 @@ main (int argc, char *const*argv)
   /* now undo updating of routing tables; normal exit or clean-up-on-error case */
  cleanup_route_4:
   {
-    char *const route_clean_args[] =                   
+    char *const route_clean_args[] =
       {
        "ip", "route", "del", "default", "dev", dev,
        "table", DNS_TABLE, NULL
@@ -1014,7 +1023,7 @@ main (int argc, char *const*argv)
        "ip", "rule", "del", "fwmark", DNS_MARK, "table", DNS_TABLE, NULL
       };
     if (0 != fork_and_exec (sbin_ip, forward_clean_args))
-      r += 2;  
+      r += 2;
   }
  cleanup_mark_2:
   {
@@ -1025,7 +1034,7 @@ main (int argc, char *const*argv)
       };
     if (0 != fork_and_exec (sbin_iptables, mark_clean_args))
       r += 4;
-  }    
+  }
  cleanup_mangle_1:
   {
     char *const mangle_clean_args[] =
@@ -1043,6 +1052,9 @@ main (int argc, char *const*argv)
   (void) close (fd_tun);
   /* remove signal handler so we can close the pipes */
   (void) signal (SIGTERM, SIG_IGN);
+#if (SIGTERM != GNUNET_TERM_SIG)
+    (void) signal (GNUNET_TERM_SIG, SIG_IGN);
+#endif
   (void) signal (SIGINT, SIG_IGN);
   (void) signal (SIGHUP, SIG_IGN);
   (void) close (cpipe[0]);