[Pkg-privacy-commits] [onioncat] 96/241: ether_ntoa() introduced (instead of self-written function) header files consolidated configure.ac bugfixes and enhancements compiles on freebsd and openbsd again now

Intrigeri intrigeri at moszumanska.debian.org
Wed Aug 26 16:16:40 UTC 2015


This is an automated email from the git hooks/post-receive script.

intrigeri pushed a commit to branch upstream-master
in repository onioncat.

commit f225ca4d7c80db8cc06d0ab24d285e70ff3885ac
Author: eagle <eagle at 58e1ccc2-750e-0410-8d0d-f93ca75ab447>
Date:   Wed Dec 10 20:21:44 2008 +0000

    ether_ntoa() introduced (instead of self-written function)
    header files consolidated
    configure.ac bugfixes and enhancements
    compiles on freebsd and openbsd again now
    
    
    git-svn-id: https://www.cypherpunk.at/svn/onioncat/trunk@387 58e1ccc2-750e-0410-8d0d-f93ca75ab447
---
 ChangeLog           |  2 ++
 TODO                |  1 +
 config.h.in         |  6 +++++
 configure           |  9 +++++---
 configure.ac        |  9 ++++----
 src/ocat.c          | 27 +---------------------
 src/ocat.h          | 64 +++++++++++++++++++++++++++++++++++++++++++++--------
 src/ocatctrl.c      | 10 ---------
 src/ocateth.c       | 55 +++------------------------------------------
 src/ocatipv4route.c | 12 ----------
 src/ocatipv6route.c | 13 -----------
 src/ocatlibe.c      |  7 ------
 src/ocatlog.c       | 11 ---------
 src/ocatpeer.c      |  7 ------
 src/ocatroute.c     | 28 -----------------------
 src/ocatsetup.c     | 15 ++++---------
 src/ocatsocks.c     | 25 ---------------------
 src/ocatthread.c    |  7 ------
 src/ocattun.c       | 30 ++++---------------------
 src/ocatv6conv.c    |  5 -----
 20 files changed, 86 insertions(+), 257 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 10a6178..5f7fc66 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,6 @@
 * version 
+ - consolidated header files
+ - compiles on FreeBSD and OpenBSD
  - connecting logfile to /dev/null if background option given
  - staying in foreground if failed to open message logfile
  - bugfixes
diff --git a/TODO b/TODO
index c5cd632..1b5e8ab 100644
--- a/TODO
+++ b/TODO
@@ -1,3 +1,4 @@
+* sometimes a peer is connected a second time for an unknown reason
 * forward multicasting packets (ff00::/8)
 * frame checking may be improved
 * generally improve tun opening routine
diff --git a/config.h.in b/config.h.in
index 92c804e..e681ab5 100644
--- a/config.h.in
+++ b/config.h.in
@@ -21,9 +21,15 @@
 /* Define to 1 if you have the <linux/sockios.h> header file. */
 #undef HAVE_LINUX_SOCKIOS_H
 
+/* Define to 1 if you have the <netinet/ether.h> header file. */
+#undef HAVE_NETINET_ETHER_H
+
 /* Define to 1 if you have the <netinet/icmp6.h> header file. */
 #undef HAVE_NETINET_ICMP6_H
 
+/* Define to 1 if you have the <netinet/if_ether.h> header file. */
+#undef HAVE_NETINET_IF_ETHER_H
+
 /* Define to 1 if you have the <netinet/in6.h> header file. */
 #undef HAVE_NETINET_IN6_H
 
diff --git a/configure b/configure
index 02a2205..9185f94 100755
--- a/configure
+++ b/configure
@@ -2170,7 +2170,6 @@ am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'
 
 
 
-#AC_CONFIG_SRCDIR([ocatroute.c])
 ac_config_headers="$ac_config_headers config.h"
 
 
@@ -3392,7 +3391,6 @@ fi
 
 # Checks for header files.
 #AC_HEADER_STDC
-#AC_CHECK_HEADERS([arpa/inet.h fcntl.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h unistd.h])
 
 
 
@@ -3408,7 +3406,9 @@ fi
 
 
 
-for ac_header in sys/types.h sys/socket.h netinet/in.h netinet/in_systm.h netinet/ip.h netinet/ip6.h netinet/in6.h net/if.h net/if_tun.h linux/if_tun.h linux/sockios.h endian.h sys/endian.h net/ethernet.h netinet/icmp6.h
+
+
+for ac_header in sys/types.h sys/socket.h netinet/in.h netinet/in_systm.h netinet/ip.h netinet/ip6.h netinet/in6.h net/if.h net/if_tun.h linux/if_tun.h linux/sockios.h endian.h sys/endian.h netinet/icmp6.h net/ethernet.h netinet/if_ether.h netinet/ether.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for $ac_header" >&5
@@ -3435,6 +3435,9 @@ cat >>conftest.$ac_ext <<_ACEOF
 #ifdef HAVE_NETINET_IN_SYSTM_H
 #include <netinet/in_systm.h>
 #endif
+#ifdef HAVE_NET_IF_H
+#include <net/if.h>
+#endif
 
 
 
diff --git a/configure.ac b/configure.ac
index ffac0a4..3b49da1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,10 +1,7 @@
-#                                               -*- Autoconf -*-
-# Process this file with autoconf to produce a configure script.
 
 AC_PREREQ(2.61)
 AC_INIT([onioncat], [0.1.9], [rahra at cypherpunk.at])
 AM_INIT_AUTOMAKE([-Wall -Werror])
-#AC_CONFIG_SRCDIR([ocatroute.c])
 AC_CONFIG_HEADERS([config.h])
 
 AC_SUBST([CFLAGS], [-Wall])
@@ -25,8 +22,7 @@ AC_CHECK_LIB([pthread], [pthread_create])
 
 # Checks for header files.
 #AC_HEADER_STDC
-#AC_CHECK_HEADERS([arpa/inet.h fcntl.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h unistd.h])
-AC_CHECK_HEADERS([sys/types.h sys/socket.h netinet/in.h netinet/in_systm.h netinet/ip.h netinet/ip6.h netinet/in6.h net/if.h net/if_tun.h linux/if_tun.h linux/sockios.h endian.h sys/endian.h net/ethernet.h netinet/icmp6.h], [], [],
+AC_CHECK_HEADERS([sys/types.h sys/socket.h netinet/in.h netinet/in_systm.h netinet/ip.h netinet/ip6.h netinet/in6.h net/if.h net/if_tun.h linux/if_tun.h linux/sockios.h endian.h sys/endian.h netinet/icmp6.h net/ethernet.h netinet/if_ether.h netinet/ether.h], [], [],
 [[
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
@@ -40,6 +36,9 @@ AC_CHECK_HEADERS([sys/types.h sys/socket.h netinet/in.h netinet/in_systm.h netin
 #ifdef HAVE_NETINET_IN_SYSTM_H
 #include <netinet/in_systm.h>
 #endif
+#ifdef HAVE_NET_IF_H
+#include <net/if.h>
+#endif
 ]]
 )
 
diff --git a/src/ocat.c b/src/ocat.c
index b936edf..6809791 100644
--- a/src/ocat.c
+++ b/src/ocat.c
@@ -15,25 +15,6 @@
  * along with OnionCat. If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdarg.h>
-#include <arpa/inet.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <pwd.h>
-#include <errno.h>
-#include <time.h>
-#include <pthread.h>
-#ifdef HAVE_NET_IF_H
-#include <net/if.h>
-#endif
 
 #include "ocat.h"
 
@@ -284,13 +265,7 @@ int main(int argc, char *argv[])
 
    memcpy(&CNF(ocat_hwaddr[3]), &CNF(ocat_addr.s6_addr[13]), 3);
    if (CNF(use_tap));
-   {
-      log_msg(LOG_INFO, "MAC address %02x:%02x:%02x:%02x:%02x:%02x",
-            CNF(ocat_hwaddr[0]), CNF(ocat_hwaddr[1]), CNF(ocat_hwaddr[2]), CNF(ocat_hwaddr[3]), CNF(ocat_hwaddr[4]), CNF(ocat_hwaddr[5]));
-      /*if (pipe(CNF(icmpv6fd)) == -1)
-         log_msg(LOG_EMERG, "cannot create multicast pipe: %s", strerror(errno)), exit(1);
-      run_ocat_thread("icmpv6", icmpv6_handler, NULL);*/
-   }
+      log_msg(LOG_INFO, "MAC address %s", ether_ntoa((struct ether_addr*) CNF(ocat_hwaddr)));
 
 #ifndef WITHOUT_TUN
    // create TUN device
diff --git a/src/ocat.h b/src/ocat.h
index 59ca7ae..d8161df 100644
--- a/src/ocat.h
+++ b/src/ocat.h
@@ -21,27 +21,73 @@
 #include "config.h"
 
 #include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <pwd.h>
+#include <errno.h>
+#include <time.h>
+#include <pthread.h>
+#include <signal.h>
+#include <ctype.h>
+#include <syslog.h>
+
+#include <arpa/inet.h>
+
+#include <sys/time.h>
+#include <sys/select.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#ifdef HAVE_ENDIAN_H
+#include <endian.h>
+#elif HAVE_SYS_ENDIAN_H
+#include <sys/endian.h>
+#endif
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
-#include <time.h>
 #ifdef HAVE_NETINET_IN_H
 #include <netinet/in.h>
 #endif
+#ifdef HAVE_NETINET_IN_SYSTM_H
+#include <netinet/in_systm.h>
+#endif
+#ifdef HAVE_NET_IF_H
+#include <net/if.h>
+#endif
+#ifdef HAVE_NETINET_IP_H
+#include <netinet/ip.h>
+#endif
+#ifdef HAVE_NETINET_ICMP6_H
+#include <netinet/icmp6.h>
+#endif
+#ifdef HAVE_NETINET_ETHER_H
+#include <netinet/ether.h>
+#endif
+#ifdef HAVE_NETINET_IF_ETHER_H
+#include <netinet/if_ether.h>
+#endif
 #ifdef HAVE_NETINET_IP6_H
 #include <netinet/ip6.h>
 #endif
-#include <pthread.h>
-#ifdef HAVE_ENDIAN_H
-#include <endian.h>
-#elif HAVE_SYS_ENDIAN_H
-#include <sys/endian.h>
-#endif
 #ifdef HAVE_NET_ETHERNET_H
 #include <net/ethernet.h>
 #endif
-#include <netinet/icmp6.h>
-#include <syslog.h>
+#ifdef HAVE_LINUX_SOCKIOS_H
+#include <linux/sockios.h>
+#endif
+#ifdef HAVE_LINUX_IF_TUN_H
+#include <linux/if_tun.h>
+#endif
+#ifdef HAVE_NET_IF_TUN_H
+#include <net/if_tun.h>
+#endif
 
 #ifndef ETHERTYPE_IPV6
 #define ETHERTYPE_IPV6 0x86dd
diff --git a/src/ocatctrl.c b/src/ocatctrl.c
index 22689b7..66fd6a5 100644
--- a/src/ocatctrl.c
+++ b/src/ocatctrl.c
@@ -22,16 +22,6 @@
  *  @version 2008/02/03-01
  */
 
-#include "config.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <pthread.h>
-#include <arpa/inet.h>
-#include <errno.h>
-#include <sys/socket.h>
 
 #include "ocat.h"
 
diff --git a/src/ocateth.c b/src/ocateth.c
index 82da20e..d588a8c 100644
--- a/src/ocateth.c
+++ b/src/ocateth.c
@@ -22,36 +22,6 @@
  *  @version 2008/10/10
  */
 
-#include "config.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <pthread.h>
-#include <arpa/inet.h>
-#include <errno.h>
-#include <sys/time.h>
-#include <sys/select.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#ifdef HAVE_LINUX_SOCKIOS_H
-#include <linux/sockios.h>
-#endif
-#ifdef HAVE_NETINET_IN_SYSTM_H
-#include <netinet/in_systm.h>
-#endif
-#ifdef HAVE_NETINET_IP_H
-#include <netinet/ip.h>
-#endif
-#include <netinet/in.h>
-#include <netinet/icmp6.h>
-/*#ifdef HAVE_NETINET_IF_ETHER_H
-#include <netinet/if_ether.h>
-#endif*/
 
 #include "ocat.h"
 
@@ -71,24 +41,6 @@ static pthread_mutex_t mac_mutex_ = PTHREAD_MUTEX_INITIALIZER;
  * IPv4 Ethernet Multicast: 01:00:5e:0xx:xx:xx, */
 
 
-/*! Convert an ethernet hardware address to a string.
- *  @param hwaddr Pointer to hardware address. Must be of len ETHER_ADDR_LEN (6).
- *  @param str Pointer to string. Must have at least 18 bytes!
- */
-char *mac_hw2str(const uint8_t *hwaddr, char *str)
-{
-   char *s = str;
-   int i;
-
-   for (i = 0; i < ETHER_ADDR_LEN; i++, str += 3, hwaddr++)
-      sprintf(str, "%02x:", *hwaddr);
-   str--;
-   *str = '\0';
-
-   return s;
-}
-
-
 void print_mac_tbl(FILE *f)
 {
    int i;
@@ -99,8 +51,7 @@ void print_mac_tbl(FILE *f)
 
    for (i = 0; i < mac_cnt_; i++)
    {
-      mac_hw2str(mac_tbl_[i].hwaddr, buf);
-      fprintf(f, "%3d %3d %s ", i, (int) (time(NULL) - mac_tbl_[i].age), buf);
+      fprintf(f, "%3d %3d %s ", i, (int) (time(NULL) - mac_tbl_[i].age), ether_ntoa((struct ether_addr*) mac_tbl_[i].hwaddr));
       fprintf(f, "%s ", mac_tbl_[i].family == AF_INET6 ? "IN6" : "IN ");
       inet_ntop(mac_tbl_[i].family, &mac_tbl_[i].in6addr, buf, INET6_ADDRSTRLEN);
       fprintf(f, "%s\n", buf);
@@ -342,14 +293,14 @@ int ndp_soladv(char *buf, int rlen)
    ndp6_t *ndp6 = (ndp6_t*) (buf + 4);
    struct nd_opt_hdr *ohd = (struct nd_opt_hdr*) (ndp6 + 1);
    uint16_t *ckb, cksum;
-   char mb[100];
+   //char mb[100];
 
    if (ndp6->eth.ether_dhost[0] & 1)
    {
       // check for right multicast destination on ethernet
       if (ndp6->eth.ether_dhost[2] != 0xff)
       {
-         log_debug("ethernet multicast destination %s cannot be solicited node address", mac_hw2str(ndp6->eth.ether_dhost, mb));
+         log_debug("ethernet multicast destination %s cannot be solicited node address", ether_ntoa((struct ether_addr*) ndp6->eth.ether_dhost));
          return -1;
       }
 
diff --git a/src/ocatipv4route.c b/src/ocatipv4route.c
index eda7dd6..ee52eff 100644
--- a/src/ocatipv4route.c
+++ b/src/ocatipv4route.c
@@ -23,18 +23,6 @@
  *  @version 2008/09/03-01
  */
 
-#include "config.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <string.h>
-#include <arpa/inet.h>
-#include <pthread.h>
-#include <errno.h>
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
 
 #include "ocat.h"
 
diff --git a/src/ocatipv6route.c b/src/ocatipv6route.c
index c1a1e5e..d1c8968 100644
--- a/src/ocatipv6route.c
+++ b/src/ocatipv6route.c
@@ -23,19 +23,6 @@
  *  @version 2008/09/03-01
  */
 
-#include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <arpa/inet.h>
-#include <errno.h>
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
 
 #include "ocat.h"
 
diff --git a/src/ocatlibe.c b/src/ocatlibe.c
index c894a41..d7f1dfe 100644
--- a/src/ocatlibe.c
+++ b/src/ocatlibe.c
@@ -22,13 +22,6 @@
  *  @version 2008/02/03-01
  */
 
-#include "config.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
 
 #include "ocat.h"
 
diff --git a/src/ocatlog.c b/src/ocatlog.c
index 4008322..0024a52 100644
--- a/src/ocatlog.c
+++ b/src/ocatlog.c
@@ -15,17 +15,6 @@
  * along with OnionCat. If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdarg.h>
-#include <errno.h>
-#include <time.h>
-#include <pthread.h>
-#include <sys/stat.h>
 
 #include "ocat.h"
 
diff --git a/src/ocatpeer.c b/src/ocatpeer.c
index 97d9f31..9ae9ad2 100644
--- a/src/ocatpeer.c
+++ b/src/ocatpeer.c
@@ -23,13 +23,6 @@
  *  @version 2008/02/03-01
  */
 
-#include "config.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <pthread.h>
-#include <errno.h>
 
 #include "ocat.h"
 
diff --git a/src/ocatroute.c b/src/ocatroute.c
index 366df2d..f80da8c 100644
--- a/src/ocatroute.c
+++ b/src/ocatroute.c
@@ -23,34 +23,6 @@
  *  @version 2008/02/03-01
  */
 
-#include "config.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <pthread.h>
-#include <arpa/inet.h>
-#include <errno.h>
-#include <sys/time.h>
-#include <sys/select.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#ifdef HAVE_LINUX_SOCKIOS_H
-#include <linux/sockios.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-#ifdef HAVE_NETINET_IN_SYSTM_H
-#include <netinet/in_systm.h>
-#endif
-#ifdef HAVE_NETINET_IP_H
-#include <netinet/ip.h>
-#endif
 
 #include "ocat.h"
 
diff --git a/src/ocatsetup.c b/src/ocatsetup.c
index f48cca8..beb9b47 100644
--- a/src/ocatsetup.c
+++ b/src/ocatsetup.c
@@ -22,12 +22,6 @@
  *  @version 2008/02/03-01
  */
 
-#include "config.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <arpa/inet.h>
-#include <sys/socket.h>
 
 #include "ocat.h"
 
@@ -67,20 +61,19 @@ void init_setup(void)
 
 void print_setup_struct(FILE *f)
 {
-   char ip[_SB], nm[_SB], ip6[_SB], hw[_SB], logf[_SB], rp[ROOT_PEERS][_SB];
+   char ip[_SB], nm[_SB], ip6[_SB], logf[_SB], rp[ROOT_PEERS][_SB];
    int i;
 
    inet_ntop(AF_INET, &setup_.ocat_addr4, ip, _SB);
    inet_ntop(AF_INET, &setup_.ocat_addr4_mask, nm, _SB);
    inet_ntop(AF_INET6, &setup_.ocat_addr, ip6, _SB);
-   mac_hw2str(setup_.ocat_hwaddr, hw);
    for (i = 0; i < ROOT_PEERS; i++)
       inet_ntop(AF_INET6, &setup_.root_peer[i], rp[i], _SB);
 
    if (setup_.logf == stderr)
-      strcpy(logf, "stderr");
+      strlcpy(logf, "stderr", sizeof(logf));
    else
-      sprintf(logf, "%p", setup_.logf);
+      snprintf(logf, sizeof(logf), "%p", setup_.logf);
 
    fprintf(f,
          "fhd_key[IPV4(%d)]  = 0x%04x\n"
@@ -136,7 +129,7 @@ void print_setup_struct(FILE *f)
          setup_.config_file,
          setup_.config_read,
          setup_.use_tap,
-         hw,
+         ether_ntoa((struct ether_addr*) setup_.ocat_hwaddr),
          setup_.pid_file,
          setup_.logfn,
          logf,
diff --git a/src/ocatsocks.c b/src/ocatsocks.c
index 684cbf9..823b499 100644
--- a/src/ocatsocks.c
+++ b/src/ocatsocks.c
@@ -22,31 +22,6 @@
  *  @version 2008/02/03-01
  */
 
-#include "config.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <pthread.h>
-#include <arpa/inet.h>
-#include <errno.h>
-#include <sys/time.h>
-#include <sys/select.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#ifdef HAVE_LINUX_SOCKIOS_H
-#include <linux/sockios.h>
-#endif
-#ifdef HAVE_NETINET_IN_SYSTM_H
-#include <netinet/in_systm.h>
-#endif
-#ifdef HAVE_NETINET_IP_H
-#include <netinet/ip.h>
-#endif
 
 #include "ocat.h"
 
diff --git a/src/ocatthread.c b/src/ocatthread.c
index ab95a6f..796d698 100644
--- a/src/ocatthread.c
+++ b/src/ocatthread.c
@@ -22,13 +22,6 @@
  *  @version 2008/02/03-01
  */
 
-#include "config.h"
-
-#include <string.h>
-#include <stdlib.h>
-#include <pthread.h>
-#include <errno.h>
-#include <signal.h>
 
 #include "ocat.h"
 
diff --git a/src/ocattun.c b/src/ocattun.c
index b581473..1103e1c 100644
--- a/src/ocattun.c
+++ b/src/ocattun.c
@@ -24,28 +24,6 @@
 
 #ifndef WITHOUT_TUN
 
-#include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <arpa/inet.h>
-#ifdef HAVE_NET_IF_H
-#include <net/if.h>
-#endif
-#ifdef HAVE_LINUX_IF_TUN_H
-#include <linux/if_tun.h>
-#endif
-#ifdef HAVE_NET_IF_TUN_H
-#include <net/if_tun.h>
-#endif
 
 #include "ocat.h"
 
@@ -84,7 +62,7 @@ int tun_alloc(char *dev, struct in6_addr addr)
    strlcpy(dev, ifr.ifr_name, IFNAMSIZ);
    if (!CNF(use_tap))
    {
-      sprintf(buf, "ifconfig %s add %s/%d up", dev, astr, TOR_PREFIX_LEN);
+      snprintf(buf, sizeof(buf), "ifconfig %s add %s/%d up", dev, astr, TOR_PREFIX_LEN);
       log_msg(LOG_INFO, "configuring tun IP: \"%s\"", buf);
       if (system(buf) == -1)
          log_msg(LOG_ERR, "could not exec \"%s\": \"%s\"", buf, strerror(errno));
@@ -119,7 +97,7 @@ int tun_alloc(char *dev, struct in6_addr addr)
 
    if (!CNF(use_tap))
    {
-      sprintf(buf, "ifconfig tun0 inet6 %s/%d up", astr, TOR_PREFIX_LEN);
+      snprintf(buf, sizeof(buf), "ifconfig tun0 inet6 %s/%d up", astr, TOR_PREFIX_LEN);
       log_debug("setting IP on tun: \"%s\"", buf);
       if (system(buf) == -1)
          log_msg(LOG_ERR, "could not exec \"%s\": \"%s\"", buf, strerror(errno));
@@ -130,7 +108,7 @@ int tun_alloc(char *dev, struct in6_addr addr)
    // setting up IPv4 address
    if (CNF(ipv4_enable) && !CNF(use_tap))
    {
-      sprintf(buf, "ifconfig %s %s netmask %s", dev, astr4, inet_ntoa(netmask));
+      snprintf(buf, sizeof(buf), "ifconfig %s %s netmask %s", dev, astr4, inet_ntoa(netmask));
       log_msg(LOG_INFO, "configuring tun IP: \"%s\"", buf);
       if (system(buf) == -1)
          log_msg(LOG_ERR, "could not exec \"%s\": \"%s\"", buf, strerror(errno));
@@ -139,7 +117,7 @@ int tun_alloc(char *dev, struct in6_addr addr)
    // bring up tap device
    if (CNF(use_tap))
    {
-       sprintf(buf, "ifconfig %s up", dev);
+       snprintf(buf, sizeof(buf), "ifconfig %s up", dev);
       log_msg(LOG_INFO, "bringing up TAP device \"%s\"", buf);
       if (system(buf) == -1)
          log_msg(LOG_ERR, "could not exec \"%s\": \"%s\"", buf, strerror(errno));
diff --git a/src/ocatv6conv.c b/src/ocatv6conv.c
index 1388a29..d1b4547 100644
--- a/src/ocatv6conv.c
+++ b/src/ocatv6conv.c
@@ -23,11 +23,6 @@
  *  @version 2008/02/03-01
  */
 
-#include "config.h"
-
-#include <ctype.h>
-#include <string.h>
-#include <sys/types.h>
 
 #include "ocat.h"
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onioncat.git



More information about the Pkg-privacy-commits mailing list