diff options
author | Phil Davis <phil.davis@inf.org> | 2016-01-25 14:05:15 +0545 |
---|---|---|
committer | Phil Davis <phil.davis@inf.org> | 2016-01-25 14:05:15 +0545 |
commit | 74817ee23827a1591bf97bfc4e6631321e89b490 (patch) | |
tree | 2893e2a30f9f5fd60812b18d662db6a0b855538e /src/usr/local/www | |
parent | a2c5280d92c2707c27cbef318b1ced7122c32b0e (diff) | |
download | pfsense-74817ee23827a1591bf97bfc4e6631321e89b490.zip pfsense-74817ee23827a1591bf97bfc4e6631321e89b490.tar.gz |
Enhance error output when package file not found
I had a system that had upgraded but the Notes package had not managed to (re)install. In that situation the Notes item is on the Status menu but there is no notes.xml or other notes code on the the system.
When I go to Status->Notes I get:
Warning: substr_compare(): The start position cannot exceed initial string length in /usr/local/www/pkg.php ...
The warning is because realpath() returns false in this case and cannot be used is a parameter to substr_compare().
Handle this case, and make the error message more informative.
Diffstat (limited to 'src/usr/local/www')
-rwxr-xr-x | src/usr/local/www/pkg.php | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/usr/local/www/pkg.php b/src/usr/local/www/pkg.php index 005495f..c8b09e0 100755 --- a/src/usr/local/www/pkg.php +++ b/src/usr/local/www/pkg.php @@ -77,10 +77,22 @@ if ($xml == "") { } else { $pkg_xml_prefix = "/usr/local/pkg/"; $pkg_full_path = "{$pkg_xml_prefix}/{$xml}"; - if (substr_compare(realpath($pkg_full_path), $pkg_xml_prefix, 0, strlen($pkg_xml_prefix))) { - print_info_box(gettext("ERROR: Invalid path specified.")); + $pkg_realpath = realpath($pkg_full_path); + if (empty($pkg_realpath)) { + $path_error = sprintf(gettext("ERROR: Package path %s not found."), htmlspecialchars($pkg_full_path)); + } else { + if (substr_compare($pkg_realpath, $pkg_xml_prefix, 0, strlen($pkg_xml_prefix))) { + $path_error = sprintf(gettext("ERROR: Invalid path %s specified."), htmlspecialchars($pkg_full_path)); + } + } + + if (!empty($path_error)) { + include("head.inc"); + print_info_box($path_error . "<br />" . gettext("Try reinstalling the package.")); + include("foot.inc"); die; } + if (file_exists($pkg_full_path)) { $pkg = parse_xml_config_pkg($pkg_full_path, "packagegui"); } else { |