LibIDL: Fix use-after-free in GenerateWindowOrWorkerInterfaces
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run

`lexical_bases` was storing `StringView`s into `ByteString`s returned
from `LexicalPath::string()` that might no longer exist.
This commit is contained in:
Jonne Ransijn 2024-11-15 23:43:04 +01:00 committed by Andreas Kling
parent 63873f3809
commit c3783cf3bd
Notes: github-actions[bot] 2024-11-16 13:40:52 +00:00
4 changed files with 8 additions and 9 deletions

View file

@ -1250,7 +1250,7 @@ Interface& Parser::parse()
return interface; return interface;
} }
Parser::Parser(ByteString filename, StringView contents, Vector<StringView> import_base_paths) Parser::Parser(ByteString filename, StringView contents, Vector<ByteString> import_base_paths)
: import_base_paths(move(import_base_paths)) : import_base_paths(move(import_base_paths))
, filename(move(filename)) , filename(move(filename))
, input(contents) , input(contents)
@ -1258,7 +1258,7 @@ Parser::Parser(ByteString filename, StringView contents, Vector<StringView> impo
{ {
} }
Parser::Parser(Parser* parent, ByteString filename, StringView contents, Vector<StringView> import_base_paths) Parser::Parser(Parser* parent, ByteString filename, StringView contents, Vector<ByteString> import_base_paths)
: import_base_paths(move(import_base_paths)) : import_base_paths(move(import_base_paths))
, filename(move(filename)) , filename(move(filename))
, input(contents) , input(contents)

View file

@ -17,7 +17,7 @@ namespace IDL {
class Parser { class Parser {
public: public:
Parser(ByteString filename, StringView contents, Vector<StringView> import_base_paths); Parser(ByteString filename, StringView contents, Vector<ByteString> import_base_paths);
Interface& parse(); Interface& parse();
Vector<ByteString> imported_files() const; Vector<ByteString> imported_files() const;
@ -35,7 +35,7 @@ private:
Yes, Yes,
}; };
Parser(Parser* parent, ByteString filename, StringView contents, Vector<StringView> import_base_path); Parser(Parser* parent, ByteString filename, StringView contents, Vector<ByteString> import_base_path);
void assert_specific(char ch); void assert_specific(char ch);
void assert_string(StringView expected); void assert_string(StringView expected);
@ -68,7 +68,7 @@ private:
ByteString parse_identifier_ending_with_space(); ByteString parse_identifier_ending_with_space();
ByteString parse_identifier_ending_with_space_or(auto... possible_terminating_characters); ByteString parse_identifier_ending_with_space_or(auto... possible_terminating_characters);
Vector<StringView> import_base_paths; Vector<ByteString> import_base_paths;
ByteString filename; ByteString filename;
StringView input; StringView input;
LineTrackingLexer lexer; LineTrackingLexer lexer;

View file

@ -21,7 +21,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
{ {
Core::ArgsParser args_parser; Core::ArgsParser args_parser;
StringView path; StringView path;
Vector<StringView> import_base_paths; Vector<ByteString> import_base_paths;
StringView output_path = "-"sv; StringView output_path = "-"sv;
StringView depfile_path; StringView depfile_path;
StringView depfile_prefix; StringView depfile_prefix;

View file

@ -356,11 +356,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
VERIFY(!paths.is_empty()); VERIFY(!paths.is_empty());
VERIFY(!base_paths.is_empty()); VERIFY(!base_paths.is_empty());
Vector<StringView> lexical_bases; Vector<ByteString> lexical_bases;
for (auto const& base_path : base_paths) { for (auto const& base_path : base_paths) {
VERIFY(!base_path.is_empty()); VERIFY(!base_path.is_empty());
LexicalPath lexical_path(base_path); lexical_bases.append(base_path);
lexical_bases.append(lexical_path.string());
} }
// Read in all IDL files, we must own the storage for all of these for the lifetime of the program // Read in all IDL files, we must own the storage for all of these for the lifetime of the program