Diff for /embedaddon/sudo/src/net_ifs.c between versions 1.1.1.3 and 1.1.1.5

version 1.1.1.3, 2013/07/22 10:46:13 version 1.1.1.5, 2014/06/15 16:12:55
Line 1 Line 1
 /*  /*
 * Copyright (c) 1996, 1998-2005, 2007-2013 * Copyright (c) 1996, 1998-2005, 2007-2014
  *      Todd C. Miller <Todd.Miller@courtesan.com>   *      Todd C. Miller <Todd.Miller@courtesan.com>
  *   *
  * Permission to use, copy, modify, and distribute this software for any   * Permission to use, copy, modify, and distribute this software for any
Line 55  struct rtentry; Line 55  struct rtentry;
 #ifdef HAVE_STRINGS_H  #ifdef HAVE_STRINGS_H
 # include <strings.h>  # include <strings.h>
 #endif /* HAVE_STRINGS_H */  #endif /* HAVE_STRINGS_H */
   #ifdef HAVE_STDBOOL_H
   # include <stdbool.h>
   #else
   # include "compat/stdbool.h"
   #endif /* HAVE_STDBOOL_H */
 #ifdef HAVE_UNISTD_H  #ifdef HAVE_UNISTD_H
 # include <unistd.h>  # include <unistd.h>
 #endif /* HAVE_UNISTD_H */  #endif /* HAVE_UNISTD_H */
Line 79  struct rtentry; Line 84  struct rtentry;
 # include <ifaddrs.h>  # include <ifaddrs.h>
 #endif  #endif
   
   #define DEFAULT_TEXT_DOMAIN     "sudo"
   #include "gettext.h"            /* must be included before missing.h */
   
 #include "missing.h"  #include "missing.h"
 #include "alloc.h"  #include "alloc.h"
#include "error.h"#include "fatal.h"
 #include "sudo_conf.h"
 #include "sudo_debug.h"  #include "sudo_debug.h"
   
 #define DEFAULT_TEXT_DOMAIN     "sudo"  
 #include "gettext.h"  
   
 /* Minix apparently lacks IFF_LOOPBACK */  /* Minix apparently lacks IFF_LOOPBACK */
 #ifndef IFF_LOOPBACK  #ifndef IFF_LOOPBACK
 # define IFF_LOOPBACK   0  # define IFF_LOOPBACK   0
Line 111  get_net_ifs(char **addrinfo) Line 117  get_net_ifs(char **addrinfo)
     struct sockaddr_in6 *sin6;      struct sockaddr_in6 *sin6;
     char addrbuf[INET6_ADDRSTRLEN];      char addrbuf[INET6_ADDRSTRLEN];
 #endif  #endif
    int ailen, i, len, num_interfaces = 0;    int ailen, len, num_interfaces = 0;
     char *cp;      char *cp;
     debug_decl(get_net_ifs, SUDO_DEBUG_NETIF)      debug_decl(get_net_ifs, SUDO_DEBUG_NETIF)
   
    if (getifaddrs(&ifaddrs))    if (!sudo_conf_probe_interfaces() || getifaddrs(&ifaddrs) != 0)
         debug_return_int(0);          debug_return_int(0);
   
     /* Allocate space for the interfaces info string. */      /* Allocate space for the interfaces info string. */
Line 140  get_net_ifs(char **addrinfo) Line 146  get_net_ifs(char **addrinfo)
     *addrinfo = cp = emalloc(ailen);      *addrinfo = cp = emalloc(ailen);
   
     /* Store the IP addr/netmask pairs. */      /* Store the IP addr/netmask pairs. */
    for (ifa = ifaddrs, i = 0; ifa != NULL; ifa = ifa -> ifa_next) {    for (ifa = ifaddrs; ifa != NULL; ifa = ifa -> ifa_next) {
         /* Skip interfaces marked "down" and "loopback". */          /* Skip interfaces marked "down" and "loopback". */
         if (ifa->ifa_addr == NULL || ifa->ifa_netmask == NULL ||          if (ifa->ifa_addr == NULL || ifa->ifa_netmask == NULL ||
             !ISSET(ifa->ifa_flags, IFF_UP) || ISSET(ifa->ifa_flags, IFF_LOOPBACK))              !ISSET(ifa->ifa_flags, IFF_UP) || ISSET(ifa->ifa_flags, IFF_LOOPBACK))
Line 153  get_net_ifs(char **addrinfo) Line 159  get_net_ifs(char **addrinfo)
                     "%s%s/", cp == *addrinfo ? "" : " ",                      "%s%s/", cp == *addrinfo ? "" : " ",
                     inet_ntoa(sin->sin_addr));                      inet_ntoa(sin->sin_addr));
                 if (len <= 0 || len >= ailen - (*addrinfo - cp)) {                  if (len <= 0 || len >= ailen - (*addrinfo - cp)) {
                    warningx(_("load_interfaces: overflow detected"));                    warningx(U_("load_interfaces: overflow detected"));
                     goto done;                      goto done;
                 }                  }
                 cp += len;                  cp += len;
Line 162  get_net_ifs(char **addrinfo) Line 168  get_net_ifs(char **addrinfo)
                 len = snprintf(cp, ailen - (*addrinfo - cp),                  len = snprintf(cp, ailen - (*addrinfo - cp),
                     "%s", inet_ntoa(sin->sin_addr));                      "%s", inet_ntoa(sin->sin_addr));
                 if (len <= 0 || len >= ailen - (*addrinfo - cp)) {                  if (len <= 0 || len >= ailen - (*addrinfo - cp)) {
                    warningx(_("load_interfaces: overflow detected"));                    warningx(U_("load_interfaces: overflow detected"));
                     goto done;                      goto done;
                 }                  }
                 cp += len;                  cp += len;
Line 174  get_net_ifs(char **addrinfo) Line 180  get_net_ifs(char **addrinfo)
                 len = snprintf(cp, ailen - (*addrinfo - cp),                  len = snprintf(cp, ailen - (*addrinfo - cp),
                     "%s%s/", cp == *addrinfo ? "" : " ", addrbuf);                      "%s%s/", cp == *addrinfo ? "" : " ", addrbuf);
                 if (len <= 0 || len >= ailen - (*addrinfo - cp)) {                  if (len <= 0 || len >= ailen - (*addrinfo - cp)) {
                    warningx(_("load_interfaces: overflow detected"));                    warningx(U_("load_interfaces: overflow detected"));
                     goto done;                      goto done;
                 }                  }
                 cp += len;                  cp += len;
Line 183  get_net_ifs(char **addrinfo) Line 189  get_net_ifs(char **addrinfo)
                 inet_ntop(AF_INET6, &sin6->sin6_addr, addrbuf, sizeof(addrbuf));                  inet_ntop(AF_INET6, &sin6->sin6_addr, addrbuf, sizeof(addrbuf));
                 len = snprintf(cp, ailen - (*addrinfo - cp), "%s", addrbuf);                  len = snprintf(cp, ailen - (*addrinfo - cp), "%s", addrbuf);
                 if (len <= 0 || len >= ailen - (*addrinfo - cp)) {                  if (len <= 0 || len >= ailen - (*addrinfo - cp)) {
                    warningx(_("load_interfaces: overflow detected"));                    warningx(U_("load_interfaces: overflow detected"));
                     goto done;                      goto done;
                 }                  }
                 cp += len;                  cp += len;
Line 221  get_net_ifs(char **addrinfo) Line 227  get_net_ifs(char **addrinfo)
 #endif /* _ISC */  #endif /* _ISC */
     debug_decl(get_net_ifs, SUDO_DEBUG_NETIF)      debug_decl(get_net_ifs, SUDO_DEBUG_NETIF)
   
       if (!sudo_conf_probe_interfaces())
           debug_return_int(0);
   
     sock = socket(AF_INET, SOCK_DGRAM, 0);      sock = socket(AF_INET, SOCK_DGRAM, 0);
     if (sock < 0)      if (sock < 0)
        fatal(_("unable to open socket"));        fatal(U_("unable to open socket"));
   
     /*      /*
      * Get interface configuration or return.       * Get interface configuration or return.
Line 294  get_net_ifs(char **addrinfo) Line 303  get_net_ifs(char **addrinfo)
             "%s%s/", cp == *addrinfo ? "" : " ",              "%s%s/", cp == *addrinfo ? "" : " ",
             inet_ntoa(sin->sin_addr));              inet_ntoa(sin->sin_addr));
         if (len <= 0 || len >= ailen - (*addrinfo - cp)) {          if (len <= 0 || len >= ailen - (*addrinfo - cp)) {
            warningx(_("load_interfaces: overflow detected"));            warningx(U_("load_interfaces: overflow detected"));
             goto done;              goto done;
         }          }
         cp += len;          cp += len;
Line 318  get_net_ifs(char **addrinfo) Line 327  get_net_ifs(char **addrinfo)
         len = snprintf(cp, ailen - (*addrinfo - cp),          len = snprintf(cp, ailen - (*addrinfo - cp),
             "%s", inet_ntoa(sin->sin_addr));              "%s", inet_ntoa(sin->sin_addr));
         if (len <= 0 || len >= ailen - (*addrinfo - cp)) {          if (len <= 0 || len >= ailen - (*addrinfo - cp)) {
            warningx(_("load_interfaces: overflow detected"));            warningx(U_("load_interfaces: overflow detected"));
             goto done;              goto done;
         }          }
         cp += len;          cp += len;

Removed from v.1.1.1.3  
changed lines
  Added in v.1.1.1.5


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>