Ignore:
Timestamp:
Feb 17, 2009, 10:37:42 PM (16 years ago)
Author:
katerina
Message:

Lock baseline database (ticket #139) and allow list as input for PortCheckInterface (ticket #140).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_portcheck.c

    r210 r212  
    12181218/* Subroutine to add an interface
    12191219 */
     1220static void * sh_dummy_str    = NULL; /* fix clobbered by.. warning */
     1221
    12201222static int sh_portchk_add_interface (const char * str)
    12211223{
    12221224  struct in_addr   haddr;
    12231225  char errbuf[256];
     1226  char buf[64];
     1227
     1228  sh_dummy_str    = (void*) &str;
    12241229
    12251230  if (iface_initialized == 0)
     
    12291234    }
    12301235
    1231   if (0 == inet_aton(str, &haddr))
    1232     return -1;
    1233 
    1234   if (iface_list.used == SH_IFACE_MAX)
    1235     return -1;
    1236 
    1237   sl_snprintf(errbuf, sizeof(errbuf), _("interface: %s"), inet_ntoa(haddr));
    1238   SH_MUTEX_LOCK(mutex_thread_nolog);
    1239   sh_error_handle(SH_ERR_INFO, FIL__, __LINE__, 0, MSG_E_SUBGEN,
    1240                   errbuf, _("sh_portchk_add_interface"));
    1241   SH_MUTEX_UNLOCK(mutex_thread_nolog);
    1242 
    1243   memcpy (&(iface_list.iface[iface_list.used].s_addr), &(haddr.s_addr), sizeof(in_addr_t));
    1244   ++iface_list.used;
     1236  do {
     1237
     1238    while (*str == ',' || *str == ' ' || *str == '\t') ++str;
     1239
     1240    if (*str)
     1241      {
     1242        unsigned int i = 0;
     1243        while (*str && i < (sizeof(buf)-1) && *str != ',' && *str != ' ' && *str != '\t')
     1244          {
     1245            buf[i] = *str; ++str; ++i;
     1246          }
     1247        buf[i] = '\0';
     1248
     1249        if (0 == inet_aton(buf, &haddr))
     1250          return -1;
     1251
     1252        if (iface_list.used == SH_IFACE_MAX)
     1253          return -1;
     1254
     1255        sl_snprintf(errbuf, sizeof(errbuf), _("interface: %s"), inet_ntoa(haddr));
     1256        SH_MUTEX_LOCK(mutex_thread_nolog);
     1257        sh_error_handle(SH_ERR_INFO, FIL__, __LINE__, 0, MSG_E_SUBGEN,
     1258                        errbuf, _("sh_portchk_add_interface"));
     1259        SH_MUTEX_UNLOCK(mutex_thread_nolog);
     1260       
     1261        memcpy (&(iface_list.iface[iface_list.used].s_addr), &(haddr.s_addr), sizeof(in_addr_t));
     1262        ++iface_list.used;
     1263      }
     1264  } while (*str);
    12451265
    12461266  return 0;
Note: See TracChangeset for help on using the changeset viewer.