Skip to content

Commit

Permalink
gui/pkg_install_dialog: Allow license files to be automatically selec…
Browse files Browse the repository at this point in the history
…ted if it is already exist

Co-Authored-By: bookmist <[email protected]>
  • Loading branch information
nishinji and bookmist committed Sep 19, 2024
1 parent 77abeaa commit 5f2d864
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions vita3k/gui/src/pkg_install_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,23 @@ void draw_pkg_install_dialog(GuiState &gui, EmuEnvState &emuenv) {
if (draw_file_dialog) {
result = host::dialog::filesystem::open_file(pkg_path, { { "PlayStation Store Downloaded Package", { "pkg" } } });
draw_file_dialog = false;
if (result == host::dialog::filesystem::Result::SUCCESS)
ImGui::OpenPopup("install");
else if (result == host::dialog::filesystem::Result::CANCEL) {
if (result == host::dialog::filesystem::Result::SUCCESS) {
fs::ifstream infile(pkg_path.native(), std::ios::binary);
PkgHeader pkg_header{};
infile.read(reinterpret_cast<char *>(&pkg_header), sizeof(PkgHeader));

Check notice on line 54 in vita3k/gui/src/pkg_install_dialog.cpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

vita3k/gui/src/pkg_install_dialog.cpp#L54

Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20).
std::string title_id_str(pkg_header.content_id);
std::string title_id = title_id_str.substr(7, 9);
const auto work_path{ emuenv.pref_path / fmt::format("ux0/license/{}/{}.rif", title_id, pkg_header.content_id) };
if (fs::exists(work_path)) {
LOG_INFO("Found license file: {}", work_path);
fs::ifstream binfile(work_path, std::ios::in | std::ios::binary | std::ios::ate);
zRIF = rif2zrif(binfile);
ImGui::OpenPopup("install");
gui::state = "install";
} else {
ImGui::OpenPopup("install");
}
} else if (result == host::dialog::filesystem::Result::CANCEL) {
gui.file_menu.pkg_install_dialog = false;
draw_file_dialog = true;
} else {
Expand Down

0 comments on commit 5f2d864

Please sign in to comment.