Imported Upstream version 1.8.7
[debian/sudo] / plugins / sudoers / interfaces.c
index 04d5b6704fb8cda7e8ba976313ca47844bb1d80e..4dc6012a3420cd4160083daa10b2a66c7f6215af 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 2010-2012 Todd C. Miller <Todd.Miller@courtesan.com>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -18,7 +18,6 @@
 
 #include <sys/types.h>
 #include <sys/socket.h>
-#include <sys/param.h>
 #include <stdio.h>
 #ifdef STDC_HEADERS
 # include <stdlib.h>
@@ -52,6 +51,8 @@
 # define INADDR_NONE ((unsigned int)-1)
 #endif
 
+static struct interface *interfaces;
+
 /*
  * Parse a space-delimited list of IP address/netmask pairs and
  * store in a list of interface structures.
@@ -71,7 +72,7 @@ set_interfaces(const char *ai)
        *mask++ = '\0';
 
        /* Parse addr and store in list. */
-       ifp = emalloc(sizeof(*ifp));
+       ifp = ecalloc(1, sizeof(*ifp));
        if (strchr(addr, ':')) {
            /* IPv6 */
 #ifdef HAVE_STRUCT_IN6_ADDR
@@ -101,6 +102,12 @@ set_interfaces(const char *ai)
     debug_return;
 }
 
+struct interface *
+get_interfaces(void)
+{
+    return interfaces;
+}
+
 void
 dump_interfaces(const char *ai)
 {