Changeset 927d0c70c763dcf56e6f12ebe02a51688468a5c3

Show
Ignore:
Timestamp:
06/08/09 21:12:46 (3 years ago)
Author:
Neutron Soutmun <neo.neutron@…>
Children:
bae014d9f22e13f6115d53d154e6489f20ae00e4
Parents:
5987af1b79b0c1fbd4aa9d30a53ec6879853ece3
git-committer:
Neutron Soutmun <neo.neutron@…> (06/08/09 21:12:46)
Message:

Follow the flawfinder guideline

  • Reduce the vulnerability code by follow the advice of flawfinder.
  • Just finish one of the TODO lists.
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • TODO

    r8a08898 r927d0c7  
    11- new version of ipset released, need test (work ?) 
    22- write the readme. (may Suriya ?) 
    3 - using flawfinder to guideline the code vulnerability. 
  • src/rahunasd.c

    raace70f r927d0c7  
    366366  } 
    367367 
    368   sprintf(version, "Starting %s - Version %s", PROGRAM, RAHUNAS_VERSION); 
     368  snprintf(version, sizeof (version), "Starting %s - Version %s", PROGRAM,  
     369           RAHUNAS_VERSION); 
    369370  logmsg(RH_LOG_NORMAL, version); 
    370371 
  • src/rh-config.c

    r2f0141c r927d0c7  
    370370    { 
    371371      iface = (struct interfaces *)runner->data; 
    372       if (strncmp(iface->dev_internal, inf_name, strlen(inf_name)) == 0) 
     372      if (iface->dev_internal && 
     373          strncmp(iface->dev_internal, inf_name, strlen(inf_name)) == 0) 
    373374        { 
    374375          // Already in the list 
     
    388389    } 
    389390 
    390   strncpy(item->dev_internal, inf_name, 32); 
    391   sprintf(item->dev_ifb, "ifb%d", ifb_ifno); 
     391  strncpy(item->dev_internal, inf_name, sizeof (item->dev_internal)); 
     392  snprintf(item->dev_ifb, sizeof (item->dev_ifb), "ifb%d", ifb_ifno); 
    392393  item->init = 0; 
    393394  item->hit  = 1; 
     
    411412    { 
    412413      iface = (struct interfaces *)runner->data; 
    413       if (strncmp (iface->dev_internal, inf_name, strlen (inf_name)) == 0) 
     414      if (iface->dev_internal && 
     415          strncmp (iface->dev_internal, inf_name, strlen (inf_name)) == 0) 
    414416        { 
    415417          iface->hit--; 
  • src/rh-ipset.c

    raace70f r927d0c7  
    122122  req_adt_get.op = IP_SET_OP_ADT_GET; 
    123123  req_adt_get.version = IP_SET_PROTOCOL_VERSION; 
    124   strcpy(req_adt_get.set.name, name); 
     124  strncpy(req_adt_get.set.name, name, IP_SET_MAXNAMELEN); 
    125125  size = sizeof(struct ip_set_req_adt_get); 
    126126 
     
    150150{ 
    151151  unsigned int i = 0; 
     152  if (!mac) 
     153    return; 
     154 
    152155  if (strlen(mac) != ETH_ALEN * 3 - 1) 
    153156    return; 
     
    181184  static char mac_string[18] = ""; 
    182185  
    183   sprintf(mac_string, "%02X:%02X:%02X:%02X:%02X:%02X",  
     186  snprintf(mac_string, sizeof (mac_string), "%02X:%02X:%02X:%02X:%02X:%02X",  
    184187          macaddress[0], macaddress[1], macaddress[2], 
    185188          macaddress[3], macaddress[4], macaddress[5]); 
     
    261264  req.op = IP_SET_OP_FLUSH; 
    262265  req.version = IP_SET_PROTOCOL_VERSION; 
    263   strcpy(req.name, name); 
     266  strncpy(req.name, name, IP_SET_MAXNAMELEN); 
    264267 
    265268  kernel_sendto(&req, sizeof(struct ip_set_req_std)); 
     
    288291  req_max_sets.op = IP_SET_OP_MAX_SETS; 
    289292  req_max_sets.version = IP_SET_PROTOCOL_VERSION; 
    290   strcpy(req_max_sets.set.name, name); 
     293  strncpy(req_max_sets.set.name, name, IP_SET_MAXNAMELEN); 
    291294  size = sizeof(req_max_sets); 
    292295  kernel_getfrom(&req_max_sets, &size); 
  • src/rh-task-bandwidth.c

    r2f0141c r927d0c7  
    282282   
    283283  // Formating the bandwidth request 
    284   sprintf(bw_req.ip, "%s", idtoip(vs->v_map, req->id)); 
    285   sprintf(bw_req.bandwidth_max_down, "%lu",  
    286     member->bandwidth_max_down); 
    287   sprintf(bw_req.bandwidth_max_up, "%lu",  
    288     member->bandwidth_max_up); 
     284  snprintf(bw_req.ip, sizeof (bw_req.ip), "%s", idtoip(vs->v_map, req->id)); 
     285  snprintf(bw_req.bandwidth_max_down, sizeof (bw_req.bandwidth_max_down),  
     286           "%lu", member->bandwidth_max_down); 
     287  snprintf(bw_req.bandwidth_max_up, sizeof (bw_req.bandwidth_max_up), "%lu",  
     288           member->bandwidth_max_up); 
    289289   
    290290  while (max_try > 0) {  
    291291    slot_id = _get_slot_id(); 
    292     sprintf(bw_req.slot_id, "%d", slot_id); 
     292    snprintf(bw_req.slot_id, sizeof (bw_req.slot_id), "%d", slot_id); 
    293293    if (bandwidth_add(vs, &bw_req) == 0) 
    294294      break; 
     
    328328    return 0; 
    329329 
    330   sprintf(bw_req.slot_id, "%d", slot_id); 
     330  snprintf(bw_req.slot_id, sizeof (bw_req.slot_id), "%d", slot_id); 
    331331 
    332332  if (bandwidth_del(vs, &bw_req) == 0) { 
  • src/rh-task-dbset.c

    raace70f r927d0c7  
    294294                 GDA_CONNECTION_OPTIONS_READ_ONLY, NULL); 
    295295 
    296   sprintf(select_cmd, "SELECT * FROM dbset WHERE vserver_id='%d'", 
    297           vs->vserver_config->vserver_id); 
     296  snprintf(select_cmd, sizeof (select_cmd),  
     297           "SELECT * FROM dbset WHERE vserver_id='%d'", 
     298           vs->vserver_config->vserver_id); 
    298299 
    299300  DP("SQL: %s", select_cmd); 
     
    343344  member = (struct rahunas_member *) member_node->data; 
    344345 
    345   sprintf(startsess_cmd, "INSERT INTO dbset" 
     346  snprintf(startsess_cmd, sizeof (startsess_cmd), "INSERT INTO dbset" 
    346347         "(session_id,vserver_id,username,ip,mac,session_start," 
    347348         "session_timeout,bandwidth_slot_id,bandwidth_max_down," 
     
    394395  DP("SessionID : %s", member->session_id); 
    395396 
    396   sprintf(stopsess_cmd, "DELETE FROM dbset WHERE " 
     397  snprintf(stopsess_cmd, sizeof (stopsess_cmd), "DELETE FROM dbset WHERE " 
    397398         "session_id='%s' AND username='%s' AND vserver_id='%d'", 
    398399         member->session_id,  
  • src/rh-task-memset.c

    raace70f r927d0c7  
    200200  switch (req->req_opt) { 
    201201    case RH_RADIUS_TERM_IDLE_TIMEOUT : 
    202       strcpy(cause, "idle timeout"); 
     202      strncpy(cause, "idle timeout", sizeof (cause)); 
    203203      break; 
    204204    case RH_RADIUS_TERM_SESSION_TIMEOUT : 
    205       strcpy(cause, "session timeout"); 
     205      strncpy(cause, "session timeout", sizeof (cause)); 
    206206      break; 
    207207    case RH_RADIUS_TERM_USER_REQUEST : 
    208       strcpy(cause, "user request"); 
     208      strncpy(cause, "user request", sizeof (cause)); 
    209209      break; 
    210210    case RH_RADIUS_TERM_NAS_REBOOT : 
    211       strcpy(cause, "nas reboot"); 
     211      strncpy(cause, "nas reboot", sizeof (cause)); 
    212212      break; 
    213213    case RH_RADIUS_TERM_ADMIN_RESET : 
    214       strcpy(cause, "admin reset"); 
     214      strncpy(cause, "admin reset", sizeof (cause)); 
    215215      break; 
    216216  }