config: deal gracefully with invalid dataspace cap

In scenarios where the config ROM is loaded from a report ROM or any
other non-static ROM, config might try to access an invalid dataspace
capability. This patch prevents the component from aborting in this
case.

Fixes #1914
This commit is contained in:
Johannes Schlatow 2016-03-13 18:54:49 +01:00 committed by Christian Helmuth
parent 07e10a04f9
commit febb0cc13d

View File

@ -17,6 +17,9 @@ using namespace Genode;
Xml_node _config_xml_node(Dataspace_capability config_ds) Xml_node _config_xml_node(Dataspace_capability config_ds)
{ {
if (!config_ds.valid())
throw Exception();
return Xml_node(env()->rm_session()->attach(config_ds), return Xml_node(env()->rm_session()->attach(config_ds),
Genode::Dataspace_client(config_ds).size()); Genode::Dataspace_client(config_ds).size());
} }
@ -88,6 +91,8 @@ Config *Genode::config()
PERR("Could not obtain config file"); PERR("Could not obtain config file");
} catch (Genode::Xml_node::Invalid_syntax) { } catch (Genode::Xml_node::Invalid_syntax) {
PERR("Config file has invalid syntax"); PERR("Config file has invalid syntax");
} catch(...) {
PERR("Config dataspace is invalid");
} }
} }
/* do not try again to construct 'config_inst' */ /* do not try again to construct 'config_inst' */