[BACK]Return to interfaces.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / sudo

Diff for /src/usr.bin/sudo/Attic/interfaces.c between version 1.3 and 1.4

version 1.3, 2002/01/23 23:03:24 version 1.4, 2003/03/15 21:23:54
Line 1 
Line 1 
 /*  /*
  * Copyright (c) 1996, 1998-2001 Todd C. Miller <Todd.Miller@courtesan.com>   * Copyright (c) 1996, 1998-2003 Todd C. Miller <Todd.Miller@courtesan.com>
  * All rights reserved.   * All rights reserved.
  *   *
  * Redistribution and use in source and binary forms, with or without   * Redistribution and use in source and binary forms, with or without
Line 99 
Line 99 
 #include "interfaces.h"  #include "interfaces.h"
   
 #ifndef lint  #ifndef lint
 static const char rcsid[] = "$Sudo: interfaces.c,v 1.63 2002/01/18 19:17:07 millert Exp $";  static const char rcsid[] = "$Sudo: interfaces.c,v 1.68 2003/03/15 20:31:02 millert Exp $";
 #endif /* lint */  #endif /* lint */
   
   
Line 121 
Line 121 
         return;          return;
   
     /* Allocate space for the interfaces list. */      /* Allocate space for the interfaces list. */
     for (ifa = ifaddrs; ifa -> ifa_next; 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_flags & IFF_UP) ||          if (ifa->ifa_addr == NULL || !(ifa->ifa_flags & IFF_UP) ||
             (ifa->ifa_flags & IFF_LOOPBACK))              (ifa->ifa_flags & IFF_LOOPBACK))
Line 134 
Line 134 
                 break;                  break;
         }          }
     }      }
       if (num_interfaces == 0)
           return;
     interfaces =      interfaces =
         (struct interface *) emalloc(sizeof(struct interface) * num_interfaces);          (struct interface *) emalloc2(num_interfaces, sizeof(struct interface));
   
     /* Store the ip addr / netmask pairs. */      /* Store the ip addr / netmask pairs. */
     for (ifa = ifaddrs, i = 0; ifa -> ifa_next; ifa = ifa -> ifa_next) {      for (ifa = ifaddrs, i = 0; 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_flags & IFF_UP) ||          if (ifa->ifa_addr == NULL || !(ifa->ifa_flags & IFF_UP) ||
             (ifa->ifa_flags & IFF_LOOPBACK))              (ifa->ifa_flags & IFF_LOOPBACK))
Line 191 
Line 193 
     }      }
   
     /*      /*
      * Get interface configuration or return (leaving num_interfaces 0)       * Get interface configuration or return (leaving num_interfaces == 0)
      */       */
     for (;;) {      for (;;) {
         ifconf_buf = erealloc(ifconf_buf, len);          ifconf_buf = erealloc(ifconf_buf, len);
Line 218 
Line 220 
     }      }
   
     /* Allocate space for the maximum number of interfaces that could exist. */      /* Allocate space for the maximum number of interfaces that could exist. */
     n = ifconf->ifc_len / sizeof(struct ifreq);      if ((n = ifconf->ifc_len / sizeof(struct ifreq)) == 0)
     interfaces = (struct interface *) emalloc(sizeof(struct interface) * n);          return;
       interfaces = (struct interface *) emalloc2(n, sizeof(struct interface));
   
     /* For each interface, store the ip address and netmask. */      /* For each interface, store the ip address and netmask. */
     for (i = 0; i < ifconf->ifc_len; ) {      for (i = 0; i < ifconf->ifc_len; ) {
Line 291 
Line 294 
     /* If the expected size < real size, realloc the array. */      /* If the expected size < real size, realloc the array. */
     if (n != num_interfaces) {      if (n != num_interfaces) {
         if (num_interfaces != 0)          if (num_interfaces != 0)
             interfaces = (struct interface *) erealloc(interfaces,              interfaces = (struct interface *) erealloc3(interfaces,
                 sizeof(struct interface) * num_interfaces);                  num_interfaces, sizeof(struct interface));
         else          else
             free(interfaces);              free(interfaces);
     }      }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4