Skip to content
Permalink
Browse files Browse the repository at this point in the history
Validation and encoding for Ping and Traceroute. Fixes #10355
  • Loading branch information
jim-p committed Mar 18, 2020
1 parent edc7e81 commit cc3990a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/usr/local/www/diag_ping.php
Expand Up @@ -68,6 +68,9 @@
if (($ipproto == "ipv6") && is_ipaddrv4($host)) {
$input_errors[] = gettext("When using IPv6, the target host must be an IPv6 address or hostname.");
}
if (!is_ipaddr($host) && !is_hostname($host)) {
$input_errors[] = gettext("Hostname must be a valid hostname or IP address.");
}

if (!$input_errors) {
if ($_POST) {
Expand Down Expand Up @@ -185,7 +188,7 @@
</div>

<div class="panel-body">
<pre><?= $result ?></pre>
<pre><?= htmlspecialchars($result) ?></pre>
</div>
</div>
<?php
Expand Down
5 changes: 4 additions & 1 deletion src/usr/local/www/diag_traceroute.php
Expand Up @@ -71,6 +71,9 @@
if (($ipproto == "ipv6") && is_ipaddrv4($host)) {
$input_errors[] = gettext("When using IPv6, the target host must be an IPv6 address or hostname.");
}
if (!is_ipaddr($host) && !is_hostname($host)) {
$input_errors[] = gettext("Hostname must be a valid hostname or IP address.");
}

$sourceip = $_REQUEST['sourceip'];
$ttl = $_REQUEST['ttl'];
Expand Down Expand Up @@ -183,7 +186,7 @@
<div class="panel-heading"><h2 class="panel-title"><?=gettext('Results')?></h2></div>
<div class="panel-body">
<?php
print('<pre>' . $result . '</pre>');
print('<pre>' . htmlspecialchars($result) . '</pre>');
?>
</div>
</div>
Expand Down

0 comments on commit cc3990a

Please sign in to comment.