1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 02:47:35 +00:00

FontEditor+TextEditor+Playground: Refuse to load device files

This prevents the undefined behaviour that would come up as a result of
doing so. (For example: opening "infinite" devices like /dev/full will
result in an infinite loop until exhaustion of memory)
This commit is contained in:
Idan Horowitz 2021-03-30 00:37:30 +03:00 committed by Andreas Kling
parent aff774c8ac
commit 77601e09c8
4 changed files with 31 additions and 2 deletions

View file

@ -639,6 +639,11 @@ bool TextEditorWidget::open_file(const String& path)
return false;
}
if (file->is_device()) {
GUI::MessageBox::show(window(), String::formatted("Opening \"{}\" failed: Can't open device files", path), "Error", GUI::MessageBox::Type::Error);
return false;
}
m_editor->set_text(file->read_all());
m_document_dirty = false;
m_document_opening = true;