Changeset 467 for trunk/wifidog/src/fw_iptables.c
- Timestamp:
- 02/20/05 16:29:15 (8 years ago)
- Files:
-
- 1 modified
-
trunk/wifidog/src/fw_iptables.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog/src/fw_iptables.c
r458 r467 41 41 #include "common.h" 42 42 43 #include "safe.h" 43 44 #include "conf.h" 44 45 #include "fw_iptables.h" … … 69 70 70 71 va_start(vlist, format); 71 vasprintf(&fmt_cmd, format, vlist); 72 asprintf(&cmd, "iptables %s", fmt_cmd); 72 safe_vasprintf(&fmt_cmd, format, vlist); 73 va_end(vlist); 74 75 safe_asprintf(&cmd, "iptables %s", fmt_cmd); 76 77 free(fmt_cmd); 78 73 79 debug(LOG_DEBUG, "Executing command: %s", cmd); 74 80 75 81 rc = execute(cmd, fw_quiet); 76 82 77 free(fmt_cmd);78 83 free(cmd); 79 84 … … 97 102 98 103 if (rule->block_allow == 1) { 99 mode = s trdup("ACCEPT");104 mode = safe_strdup("ACCEPT"); 100 105 } else { 101 mode = s trdup("REJECT");106 mode = safe_strdup("REJECT"); 102 107 } 103 108 … … 122 127 /* XXX The buffer command, an automatic variable, will get cleaned 123 128 * off of the stack when we return, so we strdup() it. */ 124 return(s trdup(command));129 return(safe_strdup(command)); 125 130 } 126 131 … … 189 194 config = config_get_config(); 190 195 LOCK_CONFIG(); 191 gw_interface = s trdup(config->gw_interface);196 gw_interface = safe_strdup(config->gw_interface); 192 197 gw_port = config->gw_port; 193 198 UNLOCK_CONFIG(); … … 343 348 int deleted = 0; 344 349 345 asprintf(&command, "iptables -t %s -L %s -n --line-numbers -v", table, chain);350 safe_asprintf(&command, "iptables -t %s -L %s -n --line-numbers -v", table, chain); 346 351 347 352 if ((p = popen(command, "r"))) { … … 356 361 if (sscanf(line, "%9[0-9]", rulenum) == 1) { 357 362 /* Delete the rule: */ 358 asprintf(&command2, "-t %s -D %s %s", table, chain, rulenum);363 safe_asprintf(&command2, "-t %s -D %s %s", table, chain, rulenum); 359 364 iptables_do_command(command2); 360 365 free(command2); … … 416 421 417 422 /* Look for outgoing traffic */ 418 asprintf(&script, "%s %s", "iptables", "-v -n -x -t mangle -L " TABLE_WIFIDOG_OUTGOING); 419 if (!(output = popen(script, "r"))) { 423 safe_asprintf(&script, "%s %s", "iptables", "-v -n -x -t mangle -L " TABLE_WIFIDOG_OUTGOING); 424 output = popen(script, "r"); 425 free(script); 426 if (!output) { 420 427 debug(LOG_ERR, "popen(): %s", strerror(errno)); 421 428 return -1; 422 429 } 423 free(script);424 430 425 431 /* skip the first two lines */ … … 453 459 454 460 /* Look for incoming traffic */ 455 asprintf(&script, "%s %s", "iptables", "-v -n -x -t mangle -L " TABLE_WIFIDOG_INCOMING); 456 if (!(output = popen(script, "r"))) { 461 safe_asprintf(&script, "%s %s", "iptables", "-v -n -x -t mangle -L " TABLE_WIFIDOG_INCOMING); 462 output = popen(script, "r"); 463 free(script); 464 if (!output) { 457 465 debug(LOG_ERR, "popen(): %s", strerror(errno)); 458 466 return -1; 459 467 } 460 free(script);461 468 462 469 /* skip the first two lines */
