Skip to content

Commit b492c0e

Browse files
committed
apcupsd: Validation and Encoding. Fixes #9556
1 parent 5049095 commit b492c0e

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

sysutils/pfSense-pkg-apcupsd/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
PORTNAME= pfSense-pkg-apcupsd
44
PORTVERSION= 0.3.91
5-
PORTREVISION= 4
5+
PORTREVISION= 5
66
CATEGORIES= sysutils
77
MASTER_SITES= # empty
88
DISTFILES= # empty

sysutils/pfSense-pkg-apcupsd/files/usr/local/www/apcupsd_status.php

+14-10
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,21 @@ function puts($arg) {
3838
$nis_server = check_nis_running_apcupsd();
3939

4040
if ( $_POST['strapcaccess'] ) {
41-
puts("<div class=\"panel panel-success responsive\"><div class=\"panel-heading\"><h2 class=\"panel-title\">Status information from apcupsd</h2></div>");
42-
puts("<pre>");
43-
puts("Running: apcaccess -h {$_POST['strapcaccess']} <br />");
44-
putenv("PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin");
45-
$ph = popen("apcaccess -h {$_POST['strapcaccess']} 2>&1", "r" );
46-
while ($line = fgets($ph)) {
47-
echo htmlspecialchars($line);
41+
if (is_hostname($_POST['strapcaccess'])) {
42+
puts("<div class=\"panel panel-success responsive\"><div class=\"panel-heading\"><h2 class=\"panel-title\">Status information from apcupsd</h2></div>");
43+
puts("<pre>");
44+
puts("Running: apcaccess -h " . htmlspecialchars($_POST['strapcaccess']) . " <br />");
45+
putenv("PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin");
46+
$ph = popen("apcaccess -h " . escapeshellarg($_POST['strapcaccess']) . " 2>&1", "r" );
47+
while ($line = fgets($ph)) {
48+
echo htmlspecialchars($line);
49+
}
50+
pclose($ph);
51+
puts("</pre>");
52+
puts("</div>");
53+
} else {
54+
print_input_errors(array(gettext("Invalid hostname or IP address")));
4855
}
49-
pclose($ph);
50-
puts("</pre>");
51-
puts("</div>");
5256
} elseif ($nis_server) {
5357
$nisip = (check_nis_ip_apcupsd() != ''? check_nis_ip_apcupsd() : "localhost");
5458
$nisport = (check_nis_port_apcupsd() != '' ? check_nis_port_apcupsd() : "3551");

0 commit comments

Comments
 (0)