Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/native/corehost/comhost/clsidmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ namespace
throw HResultException{ E_UNEXPECTED }; // This should never happen in Windows 7+

json_parser_t json;
if (!json.parse_raw_data(reinterpret_cast<char*>(data), size, _X("<embedded .clsidmap>")))
if (!json.parse_fully_trusted_raw_data(reinterpret_cast<char*>(data), size, _X("<embedded .clsidmap>")))
{
trace::error(_X("Embedded .clsidmap format is invalid"));
throw HResultException{ StatusCode::InvalidConfigFile };
Expand Down Expand Up @@ -178,7 +178,7 @@ namespace
return {};

json_parser_t json;
if (!json.parse_file(map_file_name))
if (!json.parse_fully_trusted_file(map_file_name))
{
trace::error(_X("File .clsidmap format is invalid"));
throw HResultException{ StatusCode::InvalidConfigFile };
Expand Down
2 changes: 1 addition & 1 deletion src/native/corehost/fxr/sdk_resolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ bool sdk_resolver::parse_global_file(pal::string_t global_file_path)
// After we're done parsing `global_file_path`, none of its contents will be referenced
// from the data private to json_parser_t; it's safe to declare it on the stack.
json_parser_t json;
if (!json.parse_file(global_file_path))
if (!json.parse_fully_trusted_file(global_file_path))
{
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/native/corehost/fxr/standalone/hostpolicy_resolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace

pal::string_t retval;
json_parser_t json;
if (!json.parse_file(deps_json))
if (!json.parse_fully_trusted_file(deps_json))
{
return retval;
}
Expand Down
4 changes: 2 additions & 2 deletions src/native/corehost/hostpolicy/deps_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ deps_json_t::rid_fallback_graph_t deps_json_t::get_rid_fallback_graph(const pal:
return rid_fallback_graph;

json_parser_t json;
if (!json.parse_file(deps_path_local))
if (!json.parse_fully_trusted_file(deps_path_local))
return rid_fallback_graph;

populate_rid_fallback_graph(json.document(), rid_fallback_graph);
Expand Down Expand Up @@ -586,7 +586,7 @@ void deps_json_t::load(bool is_framework_dependent, std::function<void(const jso
}

json_parser_t json;
if (!json.parse_file(m_deps_file))
if (!json.parse_fully_trusted_file(m_deps_file))
return;

m_valid = true;
Expand Down
14 changes: 10 additions & 4 deletions src/native/corehost/json_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ void get_line_column_from_offset(const char* data, uint64_t size, size_t offset,

} // empty namespace

bool json_parser_t::parse_raw_data(char* data, int64_t size, const pal::string_t& context)
bool json_parser_t::parse_fully_trusted_raw_data(char* data, int64_t size, const pal::string_t& context)
{
// This code assumes that the provided data is fully trusted; that is, that no portion
// of it has been provided by a hostile agent.

assert(data != nullptr);

constexpr auto flags = rapidjson::ParseFlag::kParseStopWhenDoneFlag | rapidjson::ParseFlag::kParseCommentsFlag;
Expand Down Expand Up @@ -81,10 +84,13 @@ bool json_parser_t::parse_raw_data(char* data, int64_t size, const pal::string_t
return true;
}

bool json_parser_t::parse_file(const pal::string_t& path)
bool json_parser_t::parse_fully_trusted_file(const pal::string_t& path)
{
// This code assumes that the caller has checked that the file `path` exists
// either within the bundle, or as a real file on disk.
// either within the bundle, or as a real file on disk. It also assumes
// that the contents of the target file are fully trusted; that is, that no
// portion of its contents has been provided by a hostile agent.

assert(m_data == nullptr);
assert(m_bundle_location == nullptr);

Expand Down Expand Up @@ -129,7 +135,7 @@ bool json_parser_t::parse_file(const pal::string_t& path)
data += 3;
}

return parse_raw_data(data, size, path);
return parse_fully_trusted_raw_data(data, size, path);
}

json_parser_t::~json_parser_t()
Expand Down
4 changes: 2 additions & 2 deletions src/native/corehost/json_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class json_parser_t {

const document_t& document() const { return m_document; }

bool parse_raw_data(char* data, int64_t size, const pal::string_t& context);
bool parse_file(const pal::string_t& path);
bool parse_fully_trusted_raw_data(char* data, int64_t size, const pal::string_t& context);
bool parse_fully_trusted_file(const pal::string_t& path);

json_parser_t()
: m_data(nullptr)
Expand Down
4 changes: 2 additions & 2 deletions src/native/corehost/runtime_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ bool runtime_config_t::ensure_dev_config_parsed()
// runtimeconfig.dev.json is never bundled into the single-file app.
// So, only a file on disk is processed.
json_parser_t json;
if (!json.parse_file(m_dev_path))
if (!json.parse_fully_trusted_file(m_dev_path))
{
return false;
}
Expand Down Expand Up @@ -410,7 +410,7 @@ bool runtime_config_t::ensure_parsed()
}

json_parser_t json;
if (!json.parse_file(m_path))
if (!json.parse_fully_trusted_file(m_path))
{
return false;
}
Expand Down
Loading