Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEXRootFSFetcher: Fix crash if curl fails to download rootfs definition file #1969

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions Source/Tools/FEXRootFSFetcher/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <fstream>
#include <iostream>
#include <unistd.h>
#include <optional>
#include <sstream>
#include <sys/mman.h>
#include <sys/syscall.h>
Expand Down Expand Up @@ -514,10 +515,14 @@ namespace WebFileFetcher {
return &*alloc->json_objects->emplace(alloc->json_objects->end());
}

std::vector<FileTargets> GetRootFSLinks() {
std::optional<std::vector<FileTargets>> GetRootFSLinks() {
// Decode the filetargets
std::string Data = DownloadToString(DownloadURL);

if (Data.empty()) {
return std::nullopt;
}

JsonAllocator Pool {
.PoolObject = {
.init = PoolInit,
Expand Down Expand Up @@ -1121,7 +1126,14 @@ int main(int argc, char **argv, char **const envp) {
}

if (AskForConfirmation(Question)) {
auto Targets = WebFileFetcher::GetRootFSLinks();
auto TargetReturn = WebFileFetcher::GetRootFSLinks();
if (!TargetReturn.has_value()) {
ExecWithInfo("Couldn't download rootfs list from the server. Try again in a minute or report on the fex-emu issue tracker.");
return -1;
}

auto Targets = TargetReturn.value();

if (Targets.empty()) {
ExecWithInfo("Couldn't parse rootfs definition URL.");
return -1;
Expand Down