Avoid directory traversal when reading package xml files, also check if file exists before try to read it

This commit is contained in:
Renato Botelho 2014-06-17 10:33:05 -03:00
parent d09ff9ef32
commit 69eb2e295f

View File

@ -65,9 +65,14 @@ function domTT_title($title_msg){
$xml = htmlspecialchars($_GET['xml']);
if($_POST['xml']) $xml = htmlspecialchars($_POST['xml']);
if($xml == "") {
$xml = basename($xml);
if ($xml == "") {
print_info_box_np(gettext("ERROR: No package defined."));
die;
} else if (!file_exists('/usr/local/pkg/' . $xml)) {
print_info_box_np(gettext("ERROR: XML file not found"));
die;
} else {
$pkg = parse_xml_config_pkg("/usr/local/pkg/" . $xml, "packagegui");
}