mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 09:07:44 +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:
parent
aff774c8ac
commit
77601e09c8
4 changed files with 31 additions and 2 deletions
|
@ -139,6 +139,10 @@ int main(int argc, char** argv)
|
|||
GUI::MessageBox::show(window, String::formatted("Opening \"{}\" failed: {}", path, strerror(errno)), "Error", GUI::MessageBox::Type::Error);
|
||||
return 1;
|
||||
}
|
||||
if (file->is_device()) {
|
||||
GUI::MessageBox::show(window, String::formatted("Opening \"{}\" failed: Can't open device files", path), "Error", GUI::MessageBox::Type::Error);
|
||||
return 1;
|
||||
}
|
||||
editor.set_text(file->read_all());
|
||||
}
|
||||
|
||||
|
@ -164,6 +168,11 @@ int main(int argc, char** argv)
|
|||
return;
|
||||
}
|
||||
|
||||
if (file->is_device()) {
|
||||
GUI::MessageBox::show(window, String::formatted("Opening \"{}\" failed: Can't open device files", open_path.value()), "Error", GUI::MessageBox::Type::Error);
|
||||
return;
|
||||
}
|
||||
|
||||
editor.set_text(file->read_all());
|
||||
editor.set_focus(true);
|
||||
}));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue