Changeset 927d0c70c763dcf56e6f12ebe02a51688468a5c3
- 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:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r8a08898
|
r927d0c7
|
|
| 1 | 1 | - new version of ipset released, need test (work ?) |
| 2 | 2 | - write the readme. (may Suriya ?) |
| 3 | | - using flawfinder to guideline the code vulnerability. |
-
|
raace70f
|
r927d0c7
|
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | | sprintf(version, "Starting %s - Version %s", PROGRAM, RAHUNAS_VERSION); |
| | 368 | snprintf(version, sizeof (version), "Starting %s - Version %s", PROGRAM, |
| | 369 | RAHUNAS_VERSION); |
| 369 | 370 | logmsg(RH_LOG_NORMAL, version); |
| 370 | 371 | |
-
|
r2f0141c
|
r927d0c7
|
|
| 370 | 370 | { |
| 371 | 371 | 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) |
| 373 | 374 | { |
| 374 | 375 | // Already in the list |
| … |
… |
|
| 388 | 389 | } |
| 389 | 390 | |
| 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); |
| 392 | 393 | item->init = 0; |
| 393 | 394 | item->hit = 1; |
| … |
… |
|
| 411 | 412 | { |
| 412 | 413 | 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) |
| 414 | 416 | { |
| 415 | 417 | iface->hit--; |
-
|
raace70f
|
r927d0c7
|
|
| 122 | 122 | req_adt_get.op = IP_SET_OP_ADT_GET; |
| 123 | 123 | 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); |
| 125 | 125 | size = sizeof(struct ip_set_req_adt_get); |
| 126 | 126 | |
| … |
… |
|
| 150 | 150 | { |
| 151 | 151 | unsigned int i = 0; |
| | 152 | if (!mac) |
| | 153 | return; |
| | 154 | |
| 152 | 155 | if (strlen(mac) != ETH_ALEN * 3 - 1) |
| 153 | 156 | return; |
| … |
… |
|
| 181 | 184 | static char mac_string[18] = ""; |
| 182 | 185 | |
| 183 | | sprintf(mac_string, "%02X:%02X:%02X:%02X:%02X:%02X", |
| | 186 | snprintf(mac_string, sizeof (mac_string), "%02X:%02X:%02X:%02X:%02X:%02X", |
| 184 | 187 | macaddress[0], macaddress[1], macaddress[2], |
| 185 | 188 | macaddress[3], macaddress[4], macaddress[5]); |
| … |
… |
|
| 261 | 264 | req.op = IP_SET_OP_FLUSH; |
| 262 | 265 | req.version = IP_SET_PROTOCOL_VERSION; |
| 263 | | strcpy(req.name, name); |
| | 266 | strncpy(req.name, name, IP_SET_MAXNAMELEN); |
| 264 | 267 | |
| 265 | 268 | kernel_sendto(&req, sizeof(struct ip_set_req_std)); |
| … |
… |
|
| 288 | 291 | req_max_sets.op = IP_SET_OP_MAX_SETS; |
| 289 | 292 | 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); |
| 291 | 294 | size = sizeof(req_max_sets); |
| 292 | 295 | kernel_getfrom(&req_max_sets, &size); |
-
|
r2f0141c
|
r927d0c7
|
|
| 282 | 282 | |
| 283 | 283 | // 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); |
| 289 | 289 | |
| 290 | 290 | while (max_try > 0) { |
| 291 | 291 | 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); |
| 293 | 293 | if (bandwidth_add(vs, &bw_req) == 0) |
| 294 | 294 | break; |
| … |
… |
|
| 328 | 328 | return 0; |
| 329 | 329 | |
| 330 | | sprintf(bw_req.slot_id, "%d", slot_id); |
| | 330 | snprintf(bw_req.slot_id, sizeof (bw_req.slot_id), "%d", slot_id); |
| 331 | 331 | |
| 332 | 332 | if (bandwidth_del(vs, &bw_req) == 0) { |
-
|
raace70f
|
r927d0c7
|
|
| 294 | 294 | GDA_CONNECTION_OPTIONS_READ_ONLY, NULL); |
| 295 | 295 | |
| 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); |
| 298 | 299 | |
| 299 | 300 | DP("SQL: %s", select_cmd); |
| … |
… |
|
| 343 | 344 | member = (struct rahunas_member *) member_node->data; |
| 344 | 345 | |
| 345 | | sprintf(startsess_cmd, "INSERT INTO dbset" |
| | 346 | snprintf(startsess_cmd, sizeof (startsess_cmd), "INSERT INTO dbset" |
| 346 | 347 | "(session_id,vserver_id,username,ip,mac,session_start," |
| 347 | 348 | "session_timeout,bandwidth_slot_id,bandwidth_max_down," |
| … |
… |
|
| 394 | 395 | DP("SessionID : %s", member->session_id); |
| 395 | 396 | |
| 396 | | sprintf(stopsess_cmd, "DELETE FROM dbset WHERE " |
| | 397 | snprintf(stopsess_cmd, sizeof (stopsess_cmd), "DELETE FROM dbset WHERE " |
| 397 | 398 | "session_id='%s' AND username='%s' AND vserver_id='%d'", |
| 398 | 399 | member->session_id, |
-
|
raace70f
|
r927d0c7
|
|
| 200 | 200 | switch (req->req_opt) { |
| 201 | 201 | case RH_RADIUS_TERM_IDLE_TIMEOUT : |
| 202 | | strcpy(cause, "idle timeout"); |
| | 202 | strncpy(cause, "idle timeout", sizeof (cause)); |
| 203 | 203 | break; |
| 204 | 204 | case RH_RADIUS_TERM_SESSION_TIMEOUT : |
| 205 | | strcpy(cause, "session timeout"); |
| | 205 | strncpy(cause, "session timeout", sizeof (cause)); |
| 206 | 206 | break; |
| 207 | 207 | case RH_RADIUS_TERM_USER_REQUEST : |
| 208 | | strcpy(cause, "user request"); |
| | 208 | strncpy(cause, "user request", sizeof (cause)); |
| 209 | 209 | break; |
| 210 | 210 | case RH_RADIUS_TERM_NAS_REBOOT : |
| 211 | | strcpy(cause, "nas reboot"); |
| | 211 | strncpy(cause, "nas reboot", sizeof (cause)); |
| 212 | 212 | break; |
| 213 | 213 | case RH_RADIUS_TERM_ADMIN_RESET : |
| 214 | | strcpy(cause, "admin reset"); |
| | 214 | strncpy(cause, "admin reset", sizeof (cause)); |
| 215 | 215 | break; |
| 216 | 216 | } |