mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Add error handling for config xml parsing exceptions. Fix #15860
With this change, exceptions during a config restore will no longer result in an unbootable instance.
This commit is contained in:
parent
e4b8c5b600
commit
e930812c68
@ -201,11 +201,16 @@ function parse_xml_config_raw($cffile, $rootobj, $isstring = "false") {
|
||||
}
|
||||
|
||||
while ($data = fread($fp, 4096)) {
|
||||
if (!xml_parse($xml_parser, $data, feof($fp))) {
|
||||
log_error(sprintf(gettext('XML error: %1$s at line %2$d in %3$s') . "\n",
|
||||
xml_error_string(xml_get_error_code($xml_parser)),
|
||||
xml_get_current_line_number($xml_parser),
|
||||
$cffile));
|
||||
try {
|
||||
if (!xml_parse($xml_parser, $data, feof($fp))) {
|
||||
log_error(sprintf(gettext('XML error: %1$s at line %2$d in %3$s') . "\n",
|
||||
xml_error_string(xml_get_error_code($xml_parser)),
|
||||
xml_get_current_line_number($xml_parser),
|
||||
$cffile));
|
||||
return -1;
|
||||
}
|
||||
} catch (\Throwable | \Error | \Exception $e) {
|
||||
log_error($e->getMessage());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user