summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2011-03-12 00:36:06 +0000
committerErmal <eri@pfsense.org>2011-03-12 00:36:06 +0000
commit2bf16ba278737b9837be350f4f39c305c8050048 (patch)
treee7344091409415a38b31c3729b7abb311f766cd6
parente92916d689ddd71f3fcfe40be249836e78fe281b (diff)
downloadpfsense-2bf16ba278737b9837be350f4f39c305c8050048.zip
pfsense-2bf16ba278737b9837be350f4f39c305c8050048.tar.gz
Prevent the command wol for being called without propper ip information. Reported-by: http://forum.pfsense.org/index.php/topic,34314.0.html
-rwxr-xr-xusr/local/www/services_wol.php28
1 files changed, 15 insertions, 13 deletions
diff --git a/usr/local/www/services_wol.php b/usr/local/www/services_wol.php
index e3c5b7d..cdc3e6a 100755
--- a/usr/local/www/services_wol.php
+++ b/usr/local/www/services_wol.php
@@ -54,15 +54,15 @@ if($_GET['wakeall'] <> "") {
$mac = $wolent['mac'];
$if = $wolent['interface'];
$description = $wolent['descr'];
- $bcip = gen_subnet_max(get_interface_ip($if),
- get_interface_subnet($if));
+ $ipaddr = get_interface_ip($if);
+ if (!is_ipaddr($ipaddr))
+ continue;
+ $bcip = gen_subnet_max($ipaddr, get_interface_subnet($if));
/* Execute wol command and check return code. */
- if(!mwexec("/usr/local/bin/wol -i {$bcip} {$mac}")){
+ if (!mwexec("/usr/local/bin/wol -i {$bcip} {$mac}"))
$savemsg .= sprintf(gettext('Sent magic packet to %1$s (%2$s)%3$s'),$mac, $description, ".<br>");
- }
- else {
+ else
$savemsg .= sprintf(gettext('Please check the %1$ssystem log%2$s, the wol command for %3$s (%4$s) did not complete successfully%5$s'),'<a href="/diag_logs.php">','</a>',$description,$mac,".<br>");
- }
}
}
@@ -89,14 +89,16 @@ if ($_POST || $_GET['mac']) {
if (!$input_errors) {
/* determine broadcast address */
- $bcip = gen_subnet_max(get_interface_ip($if),
- get_interface_subnet($if));
- /* Execute wol command and check return code. */
- if(!mwexec("/usr/local/bin/wol -i {$bcip} {$mac}")){
- $savemsg .= sprintf(gettext("Sent magic packet to %s."),$mac);
- }
+ $ipaddr = get_interface_ip($if);
+ if (!is_ipaddr($ipaddr))
+ $input_errors[] = gettext("A valid ip could not be found!");
else {
- $savemsg .= sprintf(gettext('Please check the %1$ssystem log%2$s, the wol command for %3$s did not complete successfully%4$s'),'<a href="/diag_logs.php">', '</a>', $mac, ".<br>");
+ $bcip = gen_subnet_max($ipaddr, get_interface_subnet($if));
+ /* Execute wol command and check return code. */
+ if(!mwexec("/usr/local/bin/wol -i {$bcip} {$mac}"))
+ $savemsg .= sprintf(gettext("Sent magic packet to %s."),$mac);
+ else
+ $savemsg .= sprintf(gettext('Please check the %1$ssystem log%2$s, the wol command for %3$s did not complete successfully%4$s'),'<a href="/diag_logs.php">', '</a>', $mac, ".<br>");
}
}
}
OpenPOWER on IntegriCloud