@@ -44,8 +44,11 @@ void get_line_column_from_offset(const char* data, uint64_t size, size_t offset,
4444
4545} // empty namespace
4646
47- bool json_parser_t::parse_raw_data (char * data, int64_t size, const pal::string_t & context)
47+ bool json_parser_t::parse_fully_trusted_raw_data (char * data, int64_t size, const pal::string_t & context)
4848{
49+ // This code assumes that the provided data is fully trusted; that is, that no portion
50+ // of it has been provided by a hostile agent.
51+
4952 assert (data != nullptr );
5053
5154 constexpr auto flags = rapidjson::ParseFlag::kParseStopWhenDoneFlag | rapidjson::ParseFlag::kParseCommentsFlag ;
@@ -81,10 +84,13 @@ bool json_parser_t::parse_raw_data(char* data, int64_t size, const pal::string_t
8184 return true ;
8285}
8386
84- bool json_parser_t::parse_file (const pal::string_t & path)
87+ bool json_parser_t::parse_fully_trusted_file (const pal::string_t & path)
8588{
8689 // This code assumes that the caller has checked that the file `path` exists
87- // either within the bundle, or as a real file on disk.
90+ // either within the bundle, or as a real file on disk. It also assumes
91+ // that the contents of the target file are fully trusted; that is, that no
92+ // portion of its contents has been provided by a hostile agent.
93+
8894 assert (m_data == nullptr );
8995 assert (m_bundle_location == nullptr );
9096
@@ -129,7 +135,7 @@ bool json_parser_t::parse_file(const pal::string_t& path)
129135 data += 3 ;
130136 }
131137
132- return parse_raw_data (data, size, path);
138+ return parse_fully_trusted_raw_data (data, size, path);
133139}
134140
135141json_parser_t ::~json_parser_t ()
0 commit comments